[Tkinter-discuss] Tkinter Menu

Michael Foord fuzzyman at voidspace.org.uk
Mon Jul 10 22:54:59 CEST 2006

Jeff Epler wrote:
> .add_XXX, .insert_XXX, .delete, and .entryconfigure are the methods
> you can use to incrementally change menus.  If the menu is not a
> tearoff, the postcommand= may give you a good way to populate the menu
> when it is about to be shown, rather than anytime its contents would
> have changed.
Thanks Jeff.

I have a menu with x number of entries. I wanted to delete all the 
entries except the last two and then rebuild the amended entries.

I couldn't find any way to determine the *number* of entries, or iterate 
over them. I ended up keeping a separate list of the entries and calling :

menu.delete(0, numMenuItems - 1)

followed by a series of inserts... It works, so I'm not worried. :-)

All the best,

> Jeff

More information about the Tkinter-discuss mailing list