Help!!! On Tkinter Menu problem!!!

Steve Holden steve at
Wed Nov 30 11:42:15 CET 2005

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

Are these top-level windows you are deleting? If so, look under 
"Protocol" in

for details of how to handle WM_DELETE_WINDOW. The handler for each 
window can delete the appropriate menu item.

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC           
PyCon TX 2006        

More information about the Python-list mailing list