menu add
Adds an entry of TYPE at the end of the menu.
PATHNAME add TYPE ?OPTION VALUE ...?
Description
TYPE is command, checkbutton, radiobutton, cascade, or separator. The options set the entry:
-label TEXT: the text of the entry.-command SCRIPT: the script thatinvokeand a click run.-accelerator TEXT: a key text at the right side, such asCtrl+S. The script binds the key itself.-underline INDEX: the character of the label to underline.-state STATE:normal,active, ordisabled.-activebackground,-activeforeground,-background,-foreground, and-font: the colors and the font of the entry. An empty value uses the option of the menu.-image,-bitmap,-compound,-hidemargin, and-columnbreak: stored forentrycget.-variable,-onvalue,-offvalue,-indicatoron,-selectcolor, and-selectimage: the options of acheckbuttonentry. Aradiobuttonentry has-valuein place of-onvalueand-offvalue.-menu PATHNAME: the menu that acascadeentry opens.
A separator has the one option -background.
Returns
An empty string.
Examples
% menu .ad -tearoff 0
> .ad add command -label Save -accelerator Ctrl+S
> .ad add checkbutton -label Wrap -variable wrap
> .ad add separator
> list [.ad index end] [.ad type 1]
2 checkbutton
Errors
% menu .ad2; .ad2 add bogus
bad menu entry type "bogus": must be cascade, checkbutton, command, radiobutton, or separator
-errorcode NONE
% menu .ad3; .ad3 add command -bogus 1
unknown option "-bogus"
-errorcode TK LOOKUP OPTION -bogus
% menu .ad4; .ad4 add
wrong # args: should be ".ad4 add type ?-option value ...?"
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1