Chapter 12. The Menu System

This chapter describes the menu system: its components, how to use them, and how they behave in a Unix and Win32 environment. Of primary interest are menubars and conventional linear menus (pulldown, option, and popup), although at chapter’s end, we do visit a new kind of menu, the pie menu.

Typically, a menu contains commands that aren’t used frequently, such as configuration options, File Open, File Close, Help, and so on. Commands that are used frequently may not be appropriate for menus and should be placed directly in the window to provide easier access for the user. Some examples of how menus might be used are for:

  • Creating a File, Edit, and Help menubar across the top of your application

  • Displaying a list of fonts from which the user can choose, with the selected font marked with a checkmark

  • Displaying a list of editing commands that become available when the user right-clicks on another object in your window (such as a Listbox or Entry widget)

  • Making a Menu pop up with a click of a button

You can build each of these different types of menus with the basic Menu widget.

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.