Menus
Class Menu implements all kinds of menus: menu bars of top-level windows, submenus, and pop-up menus. To use a Menu instance m as the menu bar for a top-level window w, set w’s configuration option menu=m. To use m as a submenu of a Menu instance x, call x.add_cascade with menu=m. To use m as a pop-up menu, call m.post.
Besides configuration options covered in Common Widget Options, a Menu instance m supports option postcommand=callable. Tkinter calls callable without arguments each time it is about to display m (because of a call to m.post or because of user actions). Use this option to update a dynamic menu just in time when necessary.
By default, a Tkinter menu shows a tear-off entry (a dashed line before other entries), which lets the user get a copy of the menu in a separate Toplevel window. Since such tear-offs are not part of user interface standards on popular platforms, you may want to disable tear-off functionality by using configuration option tearoff=0 for the menu.
Menu-Specific Methods
Besides methods common to all widgets, an instance m of class Menu supplies several menu-specific methods.
add, add_cascade, add_checkbutton, add_command, add_radiobutton, add_separator |
Adds after Methods whose names start with |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access