Menu Item Options

In addition to the menu itself, each individual menu item can be configured. The widget configuration options that apply to menu items are: -activebackground, -background, -bg, -bitmap, -font, -foreground, -fg, -image, -state, and -underline. Other options are:

-accelerator

Displays an accelerator key sequence for the menu item. The key sequence must be independently defined with a bind.

-command => callback

Pointer to a function that will be called when the menu item is selected.

-indicatoron => boolean

Determines whether to display an indicator.

-label => string

The string to use as a label for the menu item.

-menu => $ submenu

For a cascade menu, points to the menu to embed.

-offvalue => newvalue

For a checkbutton, specifies the value used when the checkbutton is off.

-onvalue => newvalue

For a checkbutton, specifies the value used when the checkbutton is on.

-selectcolor => color

For a checkbutton or radiobutton, color of the indicator when on.

-selectimage => imgptr

For a checkbutton or radiobutton, defines the image to be displayed instead of text when the radiobutton is on. Ignored if -image is not used.

-value => value

For a radiobutton, sets $ variable to the specified value when the radiobutton is selected (default is 1).

-variable => \$ variable

Associates the value of the menu item to the specified variable.

Get Perl in a Nutshell, 2nd Edition 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.