hwtk::menubutton
Create and manipulate menu widgets.
Format
hwtk::menubutton - pathName ?option value? …
Description
A hwtk::menubutton widget displays a textual label and/or image, and evaluates a command when pressed.
Standard Options
- -clientdata
- Database name: clientData
- -compound
- Database name: compound
- -cursor
- Database name: cursor
- -help
- Database name: help
- -helpcommand
- Database name: helpcommand
- -image
- Database name: image
- -state
- Database name: state
- -text
- Database name: text
- -textvariable
- Database name: textVariable
- -underline
- Database name: underline
- -width
- Database name: width
Widget-Specific Options
- -direction
- Database name: direction
- -displaystyle
- Database name: displaystyle
- -gridlayout
- Database name: gridlayout
- -menu
- Database name: menu
- -updateonselect
- Database name: updateOnSelect
Widget Command
- pathName configure ?option? ?value option value …?
- Query or modify the configuration options of the widget. If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
- pathName cget option
- Returns the current value of the configuration option given by option.
- pathName identify element x y
- Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
- pathName instate statespec ?script?
- Test the widget’s state. If script is not specified, returns 1 if the
widget state matches statespec and 0 otherwise. If script is specified,
equivalent to
if{[pathNameinstatestateSpec]}script
- pathName state ?stateSpec?
- Modify or inquire widget state. If stateSpec is
present, sets the widget state: for each flag in
stateSpec, sets the corresponding flag or clears it
if prefixed by an exclamation point. Returns a new state spec indicating
which flags were changed:
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.setchanges[pathNamestatespec]
pathNamestate$changes
- pathName clear
- Clears the menu.
- pathName item name ?arg arg …?
- Adds an item to the menu button’s menu. Possible arguments are:
- caption
- The string to be displayed in the menu.
- command
- A Tcl command to be invoked when the menu item is selected.
- accelerator
- The keyboard shortcut for the menu item (“Ctrl + N”, “Alt + I”, etc.)
- help
- The string to be displayed as a tooltip, when the mouse hovers over the menu item.
- image
- An image to accompany the text of the menu item.
- pathName itemcget tag ?are arg?
- Returns the current value of a configuration option for the entry given by index. Option may have any of the values accepted by the item widget command.
- pathName itemconfigure tag ?are arg?
- Same as configure command. Items can be configured; supports only -state option of an item.
- pathName itemdelete ?arg arg …?
- Deletes one or more items from the menu.
- pathName itemexists tag
- Returns a value specifying whether or not the given item exists in the menu; returns 1 if the item exists, or 0 if it does not.
- pathName itemlist
- Returns a list of the items contained in the menu.
- pathName select ?arg arg …?
- Selects the specified menu item.
Example
hwtk::dialog .dlg -title "::hwtk::menubutton"
set w [.dlg recess]
hwtk::menubutton $w.t -text testing -image add-16.png -compound left
pack $w.t;
$w.t item new -caption "New" -command "puts New" -accelerator "Ctrl + N" -help New
$w.t item open -caption "Open" -command "puts Open" -accelerator "Ctrl + O" -help Open
$w.t item save -caption "Save" -command "puts Save" -accelerator "Ctrl + S" -image fileSaveModel-16.png -help Save
$w.t item saveas -caption "Save As" -command "puts SaveAs" -accelerator "Ctrl + A"
$w.t item separator
$w.t item import -caption "Import"
$w.t item model -caption "Model" -command "puts Model" -parent import -accelerator "Alt + I"
$w.t item solver -caption "Solver Deck" -parent import -command "puts \"Solver Deck\""
$w.t item abaqus -caption "Abaqus Deck" -parent solver -command "puts \"Abaqus Deck\""
$w.t item permas -caption "Permas Deck" -parent solver -command "puts \"Permas Deck\""
$w.t item separator -parent solver
$w.t item radioss -caption "Radioss Deck" -parent solver -command "puts \"Radioss Deck\""
$w.t item connectors -parent import -caption "Connectors" -command "puts \"Connectors\"" -image fileImportModel-16.png
$w.t item load -caption "Load"
$w.t item results -parent load -caption "Results" -command "puts Results"
$w.t item up -parent load -caption "User Profile" -command "puts \"User Profile\""
$w.t item run -caption "Run" -accelerator "Ctrl + r"
$w.t item script -parent script -caption "Script" -command "puts Script"
$w.t item separator
$w.t item export -caption "Export"
$w.t item emodel -parent export -caption "Model" -command "puts Model" -image fileExportModel-16.png
$w.t item separator
$w.t item exit -caption "Exit" -command "puts Exit" -accelerator "Alt + F4" -image closeReverse-16.png
.dlg post