ARGH
[matches/honours.git] / research / transmission_spectroscopy / simulator / pgu-0.18 / examples / gui5.py
1 """Tables, Widgets, and Groups!
2 An example of tables and most of the included widgets.
3 """
4
5 import pygame
6 from pygame.locals import *
7
8 # the following line is not needed if pgu is installed
9 import sys; sys.path.insert(0, "..")
10
11 from pgu import gui
12
13 # Load an alternate theme to show how it is done. You can also 
14 # specify a path (absolute or relative) to your own custom theme:
15 #
16 #   app = gui.Desktop(theme=gui.Theme("path/to/theme"))
17 #
18 app = gui.Desktop()
19 app.connect(gui.QUIT,app.quit,None)
20
21 ##The table code is entered much like HTML.
22 ##::
23 c = gui.Table()
24
25
26 c.tr()
27 c.td(gui.Label("Gui Widgets"),colspan=4)
28
29 def cb():
30     print("Clicked!")
31 btn = gui.Button("Click Me!")
32 btn.connect(gui.CLICK, cb)
33
34 c.tr()
35 c.td(gui.Label("Button"))
36 c.td(btn,colspan=3)
37 ##
38
39 c.tr()
40 c.td(gui.Label("Switch"))
41 c.td(gui.Switch(False),colspan=3)
42
43 c.tr()
44 c.td(gui.Label("Checkbox"))
45 ##Note how Groups are used for Radio buttons, Checkboxes, and Tools.
46 ##::
47 g = gui.Group(value=[1,3])
48 c.td(gui.Checkbox(g,value=1))
49 c.td(gui.Checkbox(g,value=2))
50 c.td(gui.Checkbox(g,value=3))
51 ##
52
53 c.tr()
54 c.td(gui.Label("Radio"))
55 g = gui.Group()
56 c.td(gui.Radio(g,value=1))
57 c.td(gui.Radio(g,value=2))
58 c.td(gui.Radio(g,value=3))
59
60 c.tr()
61 c.td(gui.Label("Select"))
62 e = gui.Select()
63 e.add("Goat",'goat')
64 e.add("Horse",'horse')
65 e.add("Dog",'dog')
66 e.add("Pig",'pig')
67 c.td(e,colspan=3)
68
69 c.tr()
70 c.td(gui.Label("Tool"))
71 g = gui.Group(value='b')
72 c.td(gui.Tool(g,gui.Label('A'),value='a'))
73 c.td(gui.Tool(g,gui.Label('B'),value='b'))
74 c.td(gui.Tool(g,gui.Label('C'),value='c'))
75
76 c.tr()
77 c.td(gui.Label("Input"))
78 def cb():
79     print("Input received")
80 w = gui.Input(value='Cuzco',size=8)
81 w.connect("activate", cb)
82 c.td(w,colspan=3)
83
84 c.tr()
85 c.td(gui.Label("Slider"))
86 c.td(gui.HSlider(value=23,min=0,max=100,size=20,width=120),colspan=3)
87
88 c.tr()
89 c.td(gui.Label("Keysym"))
90 c.td(gui.Keysym(),colspan=3)
91
92 c.tr()
93 c.td(gui.Label("Text Area"), colspan=4, align=-1)
94
95 c.tr()
96 c.td(gui.TextArea(value="Cuzco the Goat", width=150, height=70), colspan=4)
97
98 app.run(c)
99

UCC git Repository :: git.ucc.asn.au