File: tmenu.py

package info (click to toggle)
python 1.5.1-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 11,592 kB
  • ctags: 32,695
  • sloc: ansic: 90,267; python: 73,993; makefile: 2,423; lisp: 2,097; sh: 702
file content (44 lines) | stat: -rw-r--r-- 817 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Test menus

import stdwingl

import stdwin
from stdwinevents import *

def main():
	w = stdwin.open('TestMenus')
	#
	items1 = 'Aap', 'Noot', 'Mies'
	m1 = w.menucreate('Menu-1')
	for item in items1:
		m1.additem(item, item[0])
	#
	items2 = 'Wim', 'Zus', 'Jet', 'Teun', 'Vuur'
	m2 = w.menucreate('Menu-2')
	for item in items2:
		m2.additem(item, `len(item)`)
	#
	m1.enable(1, 0)
	m2.check(1, 1)
	#
	while 1:
		type, window, detail = stdwin.getevent()
		if type == WE_CLOSE:
			break
		elif type == WE_DRAW:
			d = w.begindrawing()
			d.box(((50,50), (100,100)))
			del d
		elif type == WE_MENU:
			mp, i = detail
			if mp == m1:
				print 'Choice:', items1[i]
			elif mp == m2:
				print 'Choice:', items2[i]
			else:
				print 'Not one of my menus!'
		elif type == WE_CHAR:
			print 'Character', `detail`
	#

main()