[ Team LiB ] Previous Section Next Section

Menu Attributes

A menu has a few global attributes, and then each menu entry has many button-like attributes that describe its appearance and behavior. Table 30-5 specifies the attributes that apply globally to the menu, unless overridden by a per-entry attribute. The table uses the X resource names, which may have a capital at interior word boundaries. In Tcl commands, use all lowercase and a leading dash.

Table 30-5. Menu attribute resource names

activeBackground

Background color when the mouse is over a menu entry.

activeBorderWidth

Width of the raised border around active entries.

activeForeground

Text color when the mouse is over a menu entry.

background

The normal background color for menu entries.

borderWidth

Width of the border around the menu (except on systems where native menus are used, such as Windows).

cursor

Cursor to display when mouse is over the menu.

disabledForeground

Foreground (text) color when menu entries are disabled.

font

Default font for the text.

foreground

Foreground color. (Also fg).

postCommand

Tcl command to run just before the menu is posted.

relief

The relief style of the menu (except on systems where native menus are used such, as Windows).

selectColor

Color for selector in check and radio type entries.

takeFocus

Control focus changes from keyboard traversal.

tearOff

True if menu should contain a tear-off entry.

tearOffCommand

Command to execute when menu is torn off. Two arguments are added: the original menu and the new tear-off.

title

Title for the window created when the menu is torn off. If this is an empty string (default), the title is the text of the menubutton or cascade item from which this menu was torn off. (Tk 8.0)

type

(Read-only) normal, menubar, or tearoff. (Tk 8.0).

Table 30-6 describes the attributes for menu entries, as you would use them in a Tcl command (i.e., all lowercase with a leading dash.) The attributes for menu entries are not supported directly by the resource database. However, Example 31-6 on page 481 describes how you can use the resource database for menu entries.

Table 30-6. Attributes for menu entries

-activebackground

Background color when the mouse is over the entry.

-activeforeground

Foreground (text) color with mouse is over the entry.

-accelerator

Text to display as a reminder about keystroke binding.

-background

The normal background color.

-bitmap

A bitmap to display instead of text.

-columnbreak

Puts the entry at the start of a new column. (Tk 8.0).

-command

Tcl command to invoke when entry is invoked.

-compound

Where the image or bitmap should be placed relative to the text: bottom, center, left, right, top or none (default). (Tk 8.4)

-font

Default font for the text.

-foreground

Foreground color. (Also fg).

-hidemargin

Suppresses the margin reserved for button indicators. (Tk 8.0).

-image

Image to display instead of text or bitmap.

-indicatoron

Boolean that controls if the indicator is displayed: check and radio entries.

-label

Text to display in the menu entry.

-menu

Menu posted when cascade entry is invoked.

-offvalue

Variable value when check entry is not selected.

-onvalue

Value for Tcl variable when check entry is selected.

-selectcolor

Color for selector: check and radio entries.

-selectimage

Alternate image to use when entry is selected: check and radio entries.

-state

The state: normal, active, or disabled

-underline

Index of text character to underline.

-value

Value for Tcl variable when radiobutton entry is selected.

-variable

Tcl variable associated with the check or radio entry.

    [ Team LiB ] Previous Section Next Section