TkMenu( WidgetName, [Options]...)

Create and manipulate menu widgets.


WidgetName - a standard path-like name used to name the widget.

Options - one or many descriptors for the options that are available for this widget.


selectcolor - For menu entries that are check buttons or radio buttons, this option specifies the color to display in the indicator when the check button or radio button is selected.

tearoff - This option must have a proper boolean value, which specifies whether or not the menu should include a tear-off entry at the top. If so, it will exist as entry 0 of the menu and the other entries will number starting at 1. The default menu bindings arrange for the menu to be torn off when the tear-off entry is invoked.

title - The string will be used to title the window created when this menu is torn off. If the title is NULL, then the window will have the title of the menubutton or the text of the cascade item from which this menu was invoked.


The menu function creates a new top-level window (given by the WidgetName argument) and makes it into a menu widget. Additional options, described above, may be specified at the function call or in the option database to configure aspects of the menu such as its colors and font. The menu function returns its WidgetName argument. At the time this function is invoked, there must not exist a widget named WidgetName, but WidgetName's parent must exist.

A menu is a widget that displays a collection of one-line entries arranged in one or more columns. There exist several different types of entries, each with different properties. Entries of different types may be combined in a single menu. Menu entries are not the same as entry widgets. In fact, menu entries are not even distinct widgets; the entire menu is one widget.

To add and manipulate the various types of entries contained in the menu, see TkAdd.

A tear-off entry appears at the top of the menu if enabled with the tearoff option. It is not like other menu entries in that it cannot be created with the TkAdd command. When a tear-off entry is created it appears as a dashed line at the top of the menu. Under the default bindings, invoking the tear-off entry causes a torn-off copy to be made of the menu and all of its submenus.

Any menu can be set as a menubar for a toplevel window (see TkToplevel function for syntax). This menu's items will be displayed in a menubar across the top of the window. These menus will behave according to the interface guidelines of their platforms. For every menu set as a menubar, a clone menu is made. See the CLONES section for more information.

Certain menus in a menubar will be treated specially. On Windows, access to the Windows System menu in each window is provided. On X Windows, a special right-justified help menu is provided. In all cases, these menus must be created with the widget name of the menubar menu concatenated with the special name. So for a menubar named .menubar, on Windows, the special menu would be .menubar.system; on X Windows, the help menu would be

When TK sees a System menu on Windows, its items are appended to the system menu that the menubar is attached to. This menu has an icon representing a spacebar, and can be invoked with the mouse or by typing Alt+Spacebar. Due to limitations in the Windows API, any font changes, colors, images, bitmaps, or tearoff images will not appear in the system menu.

When TK see a Help menu on X Windows, the menu is moved to be last in the menubar and is right justified.

When a menu is set as a menubar for a toplevel window, or when a menu is torn off, a clone of the menu is made. This clone is a menu widget in its own right, but it is a child of the original. Changes in the configuration of the original are reflected in the clone. Additionally, any cascades that are pointed to are also cloned so that menu traversal will work right. Clones are destroyed when either the tearoff or menubar goes away, or when the original menu is destroyed.