Menus are the pull-down lists you’re accustomed to seeing at the top of a window (or the entire display, if you’re accustomed to seeing them that way on a Macintosh). Move the mouse cursor to the menu bar at the top and click on a name (e.g., File), and a list of selectable options pops up under the name you clicked (e.g., Open, Save). The options within a menu might trigger actions, much like clicking on a button; they may also open other “cascading” submenus that list more options, pop up dialog windows, and so on. In tkinter, there are two kinds of menus you can add to your scripts: top-level window menus and frame-based menus. The former option is better suited to whole windows, but the latter also works as a nested component.
In all recent Python releases (using Tk 8.0 and later), you can
associate a horizontal menu bar with a top-level window object
Toplevel). On Windows and Unix (X
Windows), this menu bar is displayed along the top of the window; on
some Macintosh machines, this menu replaces the one shown at the top
of the screen when the window is selected. In other words, window
menus look like you would expect on whatever underlying platform
your script runs upon.
This scheme is based on building trees of
Menu widget objects. Simply associate one
Menu with the window,
add other pull-down
as cascades of the top-level
Menu, and add entries to each of the
Menus are cross-linked with the next ...