On Windows, for example, the Quit option in this script’s File menu can be se-
lected with the mouse but also by pressing Alt, then “f,” and then “q.” You don’t
strictly have to use underline—on Windows, the first letter of a pull-down name
is a shortcut automatically, and arrow and Enter keys can be used to select pull-
down items. But explicit keys can enhance usability in large menus; for instance,
the key sequence Alt-E-S-S runs the quit action in this script’s nested submenu.
Let’s see what this translates to in the realm of the pixel. Figure 9-1 shows the window
that first appears when this script is run on Windows 7 with my system settings; it looks
different, but similar, on Unix, Macintosh, and other Windows configurations.
Figure 9-1. menu_win: a top-level window menu bar
Figure 9-2 shows the scene when the File pull down is selected. Notice that Menu widgets
are linked, not packed (or gridded)—the geometry manager doesn’t really come into
play here. If you run this script, you’ll also notice that all of its menu entries either quit
the program immediately or pop up a “Not Implemented” standard error dialog. This
example is about menus, after all, but menu selection callback handlers generally do
more useful work in practice.
Figure 9-2. The File menu pull down
510 | Chapter 9: A tkinter Tour, Part 2