Menu System Components
First, let’s take a quick tour of the components of a menu.
Menus and Menu Items
The foundation of the menu system is the Menu widget, a rectangular window that, as a result of some event, appears out of the ether and displays one or more columns of menu items. The event that causes the menu to appear is often the press of a Menubutton or keyboard character, but could just as well be a mouseclick or even a callback. The action of making a menu appear is called posting; making a menu disappear is called unposting. There are six flavors of menu item, shown in Figure 12-1: cascade, checkbutton, command, radiobutton, separator, and tearoff.
Figure 12-1. Important components of the menu system
With the exception of a separator, clicking a menu item initiates item-specific behavior, such as executing a callback, posting a menu, or perhaps setting a Perl variable. We’ll examine the various menu items in detail shortly. Briefly:
Clicking a cascade menu item posts another menu immediately to the right of the cascade. The new menu may have menu items of any number or type, including another cascade. A series of cascades are posted in quick succession from left to right, hence the menu item’s name.
A checkbutton menu item works just like the Checkbutton widget described in Chapter 4.
Clicking a command menu item invokes a callback.
A radiobutton menu item works ...
Get Mastering Perl/Tk now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.