Difference between revisions of "PGU Interface"
(→Other components) |
(→More Information) |
||
(One intermediate revision by the same user not shown) | |||
Line 112: | Line 112: | ||
p.value = 25 | p.value = 25 | ||
container.add(p, 25, 275) | container.add(p, 25, 275) | ||
− | + | </syntaxhighlight> | |
+ | =More Information= | ||
+ | http://csc.ucdavis.edu/~chaos/courses/ncaso/Projects2009/RichardWatson/physics_256_final_project_watson/code/util/pgu-0.10.6/docs/index.html | ||
− | + | https://github.com/parogers/pgu | |
+ | |||
+ | https://www.pygame.org/project/108 |
Latest revision as of 12:26, 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:
- When you download PGU from the link above
- Unzip it to a folder, remember to maintain the directory structure
- inside the folder there are other two folders named "pgu" and "data".
- 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() but this doesn't have a backgroud), 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)
For multiple screens you could create a container for each screen, and a current container. You can then set the current container to the one you wish to show.
Changing the theme
PGU has 3 built in themes ready to use (clean, default, gray) you can set which your desktop or app should use:
app = gui.Desktop(theme = gui.Theme(['clean','tools'])
app = gui.Desktop(theme = gui.Theme(['default','tools'])
app = gui.Desktop(theme = gui.Theme(['gray','tools'])
Other components
#Horizontal Slider
def HSliderMove():
print("Slider Moved")
hs = gui.HSlider(value=23,min=0,max=100,size=20,width=120)
hs.connect(gui.CHANGE, HSliderMove)
container.add(hs,25, 150)
#Vertical Slider
def VSliderMove():
print("Slider Moved")
vs = gui.VSlider(value=23,min=0,max=100,size=20,width=120)
vs.connect(gui.CHANGE, VSliderMove)
container.add(vs,25, 150)
#Horizontal Scroll Bar
def HScrollMove():
print("Scroll Bar Moved")
hsc = gui.HScrollBar(value=23,min=0,max=100,size=20,1)
hsc.connect(gui.CHANGE, HScrollMove)
container.add(hsc,50, 175)
#Vertical Scroll Bar
def VScrollMove():
print("Scroll Bar Moved")
vsc = gui.VScrollBar(value=23,min=0,max=100,size=20,1)
vsc.connect(gui.CHANGE, VScrollMove)
container.add(vsc,50, 175)
#Select / List box
def SelectChanged():
print("Select Changed")
se = gui.Select()
se.add("Goat",'goat')
se.add("Horse",'horse')
se.add("Dog",'dog')
se.add("Pig",'pig')
se.connect(gui.CHANGE, SelectChanged)
container.add(se, 25, 200)
#Text area
t = gui.TextArea(value="Some text in a test area", width=150, height=70)
container.add(t, 25, 250)
#Progress bar
p = gui.ProgressBar(0, 0, 100, width = 300)
p.value = 25
container.add(p, 25, 275)