October 28, 2016
Hot Topics:

Perl/Tk Menus: Past, Present and Future

  • August 19, 1999
  • By Steve Lidie
  • Send Email »
  • More Articles »

Tk 8 Menubars

When menubars were revamped in Tk 8 to support Macintosh and Win32 operating systems, they became even easier to use. For instance, a menu widget can be attached to any mainwindow or toplevel, and act as a menubar. This means we don't have to generate our own menubar from a frame and menubuttons. Nor do we have to worry about their geometry management. Menubuttons are now superfluous -- cascades take their place. The menu manager also looks for menu labels, like Help on Unix and System on Win32, and handles them specially. The manager also ensures that the appearance and behavior of the menubar adheres to the user interface guidelines of the running operating system. The program, menubar2, a Tk 8 version of menubar1, produced the display shown in Figure 4. The program speaks for itself.

Menu Miscellany

Menu (and menubutton) widgets accept a -menuitems parameter, a list of lists that defines all the menu items comprising a menu. Each inner list describes a single menu item, like this Exit command item:

my $mi = [ ['command' => 'E~xit', -command => \&exit] ];
my $menu = $mw->Menu(-menuitems => $mi);


Figure 5

Program menuitems2 uses a data structure like this to create Figure 3. Menus can be broken into multiple columns. If a menu item's -columnbreak attribute is true, it begins a new column (columns read left to right). Typically, multicolumn menus also set -hidemargin to true.

Figure 5 was created by this code (program colbreak).

Pie Menus

I saw my first pie menu in Scientific American (July 1997). The circular menu had numerous menu items arranged radially about its center point. The caption claimed that users could use pie menus in 30% less time that regular, linear menus, and with half the error rate. This is explained by Fitts' law, a model of human psychomotor behaviour, developed in 1954.

Fitts' law describes the time required to hit a target based on target distance and size. Unsurprisingly, for a person with a mouse, selecting a large menu item close at hand is faster than hunting for a small target far away. The linear menus we have seen thus far are one dimensional -- the cursor is always positioned at the top of the menu, making the user move the cursor down. Thus it takes longer to select a menu item at the end of the menu than at the beginning. In contrast, pie menus are two dimensional -- the cursor is initially positioned in the center of the pie, so all the wedge shaped menu items are the same distance from the cursor but in different directions. All menu items are equally accessible. Furthermore, each pie piece has a virtual section that extends from the pie's perimeter to the edge of the display. To hit such a large target requires but a gross, gestural motor movement, which your muscles easily learn and remember. If you'd like to experiment with Fitts' law, run the demonstration program fittslaw from the TPJ web site.

As luck would have it, a message appeared on the Perl/Tk mailing list from Russell Nelson asking how to integrate some pie menu code into Perl/Tk. With his permission, I've taken that code and begun the conversion. (We'll see the fruits of this ongoing work in a later column.) The code was written over seven years ago by Don Hopkins, who has been developing pie menus ever since.


Figure 6: Demo Pie Menu

Figure 6 shows an example of Don's early work. The Demo pie menu has four items, each occupying a 90 degree slice of the pie. To select an item we just need to click anywhere on the piece's sector of the screen. Notice that this pie menu is rectangular and has a background.


Figure 7: Clock Pie Menu

Figure 7 shows the "Clock" pie menu, which is circular and has no background. In fact, the appearance of pie menus can vary greatly. For more about pie menus, visit Don's pie page.

A pie menu is ideally suited for selecting two pieces of information simultaneously. Consider a word processor where we want to select a font and its size -- each font can be a pie piece, and its size is determined by how far from the center of the pie we click. Or consider a color wheel where the hues are the slices and the saturation varies from the pie's center to its circumference.

Maybe someday we'll have three-dimensional sphere menus with conical menu items. All we need is the right input device...

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel