1 # Define menu operations for GL stdwin
4 from glstdwin
import key2code
8 def _init(self
, win
, title
):
15 self
._win
.remove(self
)
18 def additem(self
, *args
):
22 text
, shortcut
= args
[0], None
24 raise TypeError, 'arg count'
25 self
._items
.append([text
, shortcut
, 1, 0])
27 def setitem(self
, i
, text
):
28 self
._items
[i
][0] = text
30 def enable(self
, i
, flag
):
31 self
._items
[i
][2] = flag
33 def check(self
, i
, flag
):
34 self
._items
[i
][3] = flag
36 def _makepup(self
, firstitem
):
39 gl
.addtopup(pup
, self
._title
+ '%t', 0)
40 for item
in self
._items
:
42 if not item
[2]: # Disabled
43 text
= ' ( ' + text
+ ' )%x-1'
45 if item
[3]: # Check mark
49 if key2code
.has_key(item
[1]):
50 text
= text
+ ' [Alt-' + item
[1] + ']'
51 text
= text
+ '%x' + `firstitem`
52 gl
.addtopup(pup
, text
, 0)
53 firstitem
= firstitem
+ 1
56 def _checkshortcut(self
, char
):
57 for i
in range(len(self
._items
)):
59 if item
[2] and item
[1] == char
: