Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

11.2. The Menubutton Widget

As described earlier, the menubutton widget has a menu that drops down from a button when the button is pressed. The menu is removed from the window when an item from the menu is selected or when the user clicks elsewhere in the application.

Many applications use a menubutton-type construct. The menubuttons are normally grouped across the top of the application and have names like File, Edit, Options, and Help. Figure 11.4 shows an example of several menubuttons grouped together in a frame.[2]

[2] You can accomplish this same look in a window by using a menubar widget. However, the additional functionality that it provides is minimal, so we won't be covering it in this book. To get this look, create a frame widget with a relief of "ridge" and borderwidth of 2. Pack the menubuttons with -side => "left" for all but the help menu, which has -side => "right".

Figure 11.4. Example of window with several menubuttons across the top

11.2.1. Creating a Menubutton

When you create a menubutton widget, use the parent widget to invoke the Menubutton method, which then creates a menubutton widget reference. The options you send with the Menubutton method can configure both the button that is initially displayed on the screen and the actual menu items:

$mbutton = $parent->Menubutton( ...
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.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata