summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1998-07-13 13:41:02 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1998-07-13 13:41:02 (GMT)
commit5c44027d8ab77fb40ec9a386596e59251c1b7146 (patch)
tree08168138f2affd89a9a23024623f94a200919310 /Mac
parentf22e67dcb5c6ce3d08e56f62b337390198ffee54 (diff)
downloadcpython-5c44027d8ab77fb40ec9a386596e59251c1b7146.zip
cpython-5c44027d8ab77fb40ec9a386596e59251c1b7146.tar.gz
cpython-5c44027d8ab77fb40ec9a386596e59251c1b7146.tar.bz2
Added a delete() method to menu entries. Only the last entry of a menu
can be deleted, but that's good enough for things like a "Windows" menu with the dynamic list of open windows at the end of the menu.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Lib/FrameWork.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Mac/Lib/FrameWork.py b/Mac/Lib/FrameWork.py
index 647d9e4..866b869 100644
--- a/Mac/Lib/FrameWork.py
+++ b/Mac/Lib/FrameWork.py
@@ -526,7 +526,7 @@ class Menu:
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)
@@ -535,6 +535,12 @@ class Menu:
if shortcut:
self.menu.SetItemCmd(item, ord(shortcut))
return item
+
+ def delitem(self, item):
+ if item != len(self.items):
+ raise 'Can only delete last item of a menu'
+ self.menu.DeleteMenuItem(item)
+ del self.items[item-1]
def addcheck(self, label, shortcut=None, callback=None):
return self.additem(label, shortcut, callback, 'check')
@@ -583,6 +589,8 @@ class Menu:
self.menu.EnableItem(0)
else:
self.menu.DisableItem(0)
+ if self.bar and self.bar.parent:
+ self.bar.parent.needmenubarredraw = 1
class PopupMenu(Menu):
def __init__(self, bar):
@@ -610,6 +618,11 @@ class MenuItem:
self.item = menu.additem(title, shortcut, callback)
self.menu = menu
+ def delete(self):
+ self.menu.delitem(self.item)
+ del self.menu
+ del self.item
+
def check(self, onoff):
self.menu.menu.CheckItem(self.item, onoff)