Difference between revisions of "PGU Interface"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Other components)
(Other components)
Line 49: Line 49:
 
=Other components=
 
=Other components=
 
<syntaxhighlight lang=python>
 
<syntaxhighlight lang=python>
 +
#Check boxes
 
g = gui.Group(value=[1,3])  
 
g = gui.Group(value=[1,3])  
 
gui.Checkbox(g,value=1)
 
gui.Checkbox(g,value=1)
Line 54: Line 55:
 
gui.Checkbox(g,value=3)
 
gui.Checkbox(g,value=3)
 
container.add(g)
 
container.add(g)
+
 
 +
#Radio buttons
 
f = gui.Group()  
 
f = gui.Group()  
 
gui.Radio(f,value=1)  
 
gui.Radio(f,value=1)  
Line 61: Line 63:
 
container.add(f)
 
container.add(f)
  
 +
#Select / List box
 
e = gui.Select()  
 
e = gui.Select()  
 
e.add("Goat",'goat')  
 
e.add("Goat",'goat')  

Revision as of 10:27, 2 July 2018

Installing PGU

Once you have downloaded the .zip file from here (select the latest version). You can then install the downloaded file, remember to check the actual path to the file. You can type the following into the search box in the python environments panel:

pip install "path/to/file/pgu-0.18.zip

if this doesn't work then you can also try:

  1. When you download PGU from the link above
  2. Unzip it to a folder, remember to maintain the directory structure
  3. inside the folder there are other two folders named "pgu" and "data".
  4. Copy them into your project's/program's root folder and you're done!

PGU Example

You firstly need to create a Desktop (or App()), we then need to connect the QUIT methods.

from pgu import gui

#create gui called app
app = gui.Desktop()

#connect quit logic to gui quit
app.connect(gui.QUIT,app.quit,None)

#container for the gui components
container = gui.Container(width=200,height=120)

#Quit button with quit logic and added onto the container
quitBtn = gui.Button("Quit")
quitBtn.connect(gui.CLICK,app.quit,None)
container.add(quitBtn,25,25)

#Method to run if click button is clicked
def Clicked():
    print("Clicked")

#Click button with logic to run the Clicked method above
clickBtn = gui.Button("Click Me!")
clickBtn.connect(gui.CLICK, Clicked)
container.add(clickBtn,25,75)

#A label with the text added to the container
container.add(gui.Label("Text Label"),25,125)

#finally add container to the app gui
app.run(container)

Other components

#Check boxes
g = gui.Group(value=[1,3]) 
gui.Checkbox(g,value=1)
gui.Checkbox(g,value=2)
gui.Checkbox(g,value=3)
container.add(g)

#Radio buttons 
f = gui.Group() 
gui.Radio(f,value=1) 
gui.Radio(f,value=2)
gui.Radio(f,value=3)
container.add(f)

#Select / List box
e = gui.Select() 
e.add("Goat",'goat') 
e.add("Horse",'horse') 
e.add("Dog",'dog') 
e.add("Pig",'pig') 
container.add(e)
 
g = gui.Group(value='b') 
gui.Tool(g,gui.Label('A'),value='a') 
gui.Tool(g,gui.Label('B'),value='b') 
gui.Tool(g,gui.Label('C'),value='c') 
container.add(e)