Xuening wrote: > I have a problem about menu by using Tkinter. I want to make a dynamic > menu. That is when I create a new view/window, one menuitem will be > added to the menu. and when I kill a window, the correponding menuitem > will be deleted. I write a simple code and I can add menuitem now. But > I don't know how to remove the item when I close the window. > [code snipped] > > > Maybe I should bind something to <destroy> event. Everytime I close the > window, the name of the window should be removed from the windowList > and refresh the all the menuitems again. But I don't know how and > where to add the "destroy" event. Can anyone give me a hand???? > > Thanks a lot!! > Well first of all I presume you understand that menus have a delete method, so you can remove items. If not, see "delete()" in
http://effbot.org/tkinterbook/menu.htm Are these top-level windows you are deleting? If so, look under "Protocol" in http://effbot.org/zone/tkinter-events-and-bindings.htm for details of how to handle WM_DELETE_WINDOW. The handler for each window can delete the appropriate menu item. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list