xref: /inferno-os/man/9/choicebutton (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
CHOICEBUTTON 9
NAME
choicebutton - create and manipulate choicebutton widgets
SYNOPSIS
\f5choicebutton pathName ?options?
STANDARD OPTIONS
.EX -activebackground -borderwidth -relief -activeforeground -font -text -anchor -foreground -background -image -bitmap -justify
"WIDGET-SPECIFIC OPTIONS"

-command command Specifies a Tk command to associate with the button. This command is typically invoked when mouse button 1 is released over the button window. The button's global variable (\f5-variable option) will be updated before the command is invoked.

-height dist Specifies a desired height for the button. If this option isn't specified, the button's desired height is computed from the size of the highest item in the -values list.

-selectcolor colour Specifies a background colour to use when the button is selected. If specified as an empty string, no special colour is used for displaying when the widget is selected.

-values list Specifies a list of all the values the choicebutton can choose from.

-variable string Specifies name of global variable to set whenever this button is selected. The variable will be set to the index of the currently selected item. Changes in this variable also cause the button to choose the appropriate item (provided it is an integer and within range).

-width dist Specifies a desired width for the button. If this option isn't specified, the button's desired width is computed from the size of the widest item in the -values list.

DESCRIPTION
The \f5choicebutton command creates a new window (given by the pathName argument) and makes it into a choicebutton widget. Additional options, described above, may be specified on the command line to configure aspects of the choicebutton such as its colours, font, text, and initial relief. The \f5choicebutton command returns its pathName argument. At the time this command is invoked, there must not exist a window named pathName.

A choicebutton is a widget that displays a textual string, one of the items given in the list argument to the -values option. When clicked on, the choicebutton displays a menu showing all the available choices, allowing the user to change the choice by selecting an item. In the description below, an index is a zero-based index into the set of values specified with the -values option.

"WIDGET COMMAND"
The \f5choicebutton command creates a new Tk command whose name is pathName. This command may be used to invoke various operations on the widget. It has the following general form:

.EX pathName option ?arg arg ...?

Option and the args determine the exact behaviour of the command. The following commands are possible for choicebutton widgets:

pathName \f5cget option Returns the current value of the configuration option given by option. Option may have any of the values accepted by the \f5choicebutton command.

pathName \f5configure ?option? ?value option value ...? Query or modify the configuration options of the widget. If no option is specified, returns a list of all of the available options for pathName. If one or more option-value pairs are specified, the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the \f5choicebutton command.

pathName \f5get ?value? Get the index of the first item with value . If value is not given, get the index of the currently selected item.

pathName \f5set index Sets the current item to the index th value.

pathName \f5getvalue ?index? Get the value of the index th item. If index is not given, get the value of the currently selected item.

pathName \f5setvalue value Set the current item to the first item having value . If no item has that value, no change is made, and an error is returned.

pathName \f5invoke index Does just what would have happened if the user invoked the choicebutton with the mouse and selected the item at index : sets the current item to index and runs its associated Tk command, if there is one. The return value is that from invoking the Tk command, or an empty string if there is no associated command.

pathName \f5valuecount Returns the number of values configured in the choicebutton.

SEE ALSO
button (9), checkbutton (9), options (9), radiobutton (9), types (9)