Added 'description' class attribute to every command class (to help the
[python/dscho.git] / Demo / sgi / gl / glstdwin / tmenu.py
blob233edae3c1640cfa2f9fba821c2c53b48ca871b5
1 # Test menus
3 import stdwingl
5 import stdwin
6 from stdwinevents import *
8 def main():
9 w = stdwin.open('TestMenus')
11 items1 = 'Aap', 'Noot', 'Mies'
12 m1 = w.menucreate('Menu-1')
13 for item in items1:
14 m1.additem(item, item[0])
16 items2 = 'Wim', 'Zus', 'Jet', 'Teun', 'Vuur'
17 m2 = w.menucreate('Menu-2')
18 for item in items2:
19 m2.additem(item, `len(item)`)
21 m1.enable(1, 0)
22 m2.check(1, 1)
24 while 1:
25 type, window, detail = stdwin.getevent()
26 if type == WE_CLOSE:
27 break
28 elif type == WE_DRAW:
29 d = w.begindrawing()
30 d.box(((50,50), (100,100)))
31 del d
32 elif type == WE_MENU:
33 mp, i = detail
34 if mp == m1:
35 print 'Choice:', items1[i]
36 elif mp == m2:
37 print 'Choice:', items2[i]
38 else:
39 print 'Not one of my menus!'
40 elif type == WE_CHAR:
41 print 'Character', `detail`
44 main()