Added checkmenu() method (to checkmark an entry) and delete() method

to remove a menu.
This commit is contained in:
Jack Jansen 1996-03-12 13:32:03 +00:00
parent e355c4568f
commit db9ff36ad9
1 changed files with 18 additions and 0 deletions

View File

@ -371,11 +371,16 @@ class MenuBar:
def addmenu(self, title, after = 0):
id = self.getnextid()
print 'Newmenu', title, id # XXXX
m = NewMenu(id, title)
m.InsertMenu(after)
DrawMenuBar()
return id, m
def delmenu(self, id):
print 'Delmenu', id # XXXX
DeleteMenu(id)
def addpopup(self, title = ''):
return self.addmenu(title, -1)
@ -402,6 +407,14 @@ class Menu:
bar.menus[self.id] = self
self.items = []
def delete(self):
self.bar.delmenu(self.id)
del self.bar.menus[self.id]
del self.bar
del self.items
del self.menu
del self.id
def additem(self, label, shortcut=None, callback=None, kind=None):
self.menu.AppendMenu('x') # add a dummy string
self.items.append(label, shortcut, callback, kind)
@ -436,6 +449,11 @@ class Menu:
class MenuItem:
def __init__(self, menu, title, shortcut=None, callback=None, kind=None):
self.item = menu.additem(title, shortcut, callback)
self.menu = menu
def check(self, onoff):
self.menu.menu.CheckItem(self.item, onoff)
class RadioItem(MenuItem):
def __init__(self, menu, title, shortcut=None, callback=None):