Documentation‎ > ‎Buttons‎ > ‎

gnocl::radioButton

A widget from which only one of a group can be selected.

Synopsis

gnocl::radioButton [-option value...]

Screenshot


Options

-active boolean
This option sets the widget active. Since one button of the group must be active, a button can only set to non active by setting another button to active. This overrides the value of the associated variable. The associated variable is set accordingly.
-data string
User defined data which can be retrieved via the cget subcommand.
-hasFocus 1
This sets the focus to the widget. To unset the focus it must be set to another widget.
-indicatorOn boolean (default: true)
Determines whether or not the toggle button is drawn on screen.
-name string
Name of the widget, can be used to set options in an rc file.
-onButtonPress string (default: "")
Tcl command which is executed if a mouse button is press inside the widget. Before evaluation the following percent strings are substituted:

%w    widget name
%t    type of event: one of buttonPress, button2Press or button3Press
%x    x coordinate
%y    y coordinate
%b    button number
%s    state of the buttons and modifiers (bitmask)
-onButtonRelease string (default: "")
Tcl command which is executed if a mouse button is released inside the widget. Before evaluation the following percent strings are substituted:

%w    widget name
%t    type of event: always buttonRelease
%x    x coordinate
%y    y coordinate
%b    button number
%s    state of the buttons and modifiers (bitmask)
-onPopupMenu string (default: "")
Tcl command which is executed if the "popup-menu" signal is received, which is normally the case if the user presses Shift-F10. Before evaluation the following percent strings are substituted:

%w    widget name.
-onShowHelp string (default: "")
Tcl command which is executed in the global scope if the "show-help" signal is received, which is normally the case if the user presses F1 or Ctrl-F1. Before evaluation the following percent strings are substituted:

%w    widget name
%h    help type: either "whatsThis" or "tooltip"
-onToggled string (default: "")
Tcl command which is executed if the radio button is toggled. Before evaluation the following percent strings are substituted:

%w    widget name
%v    value of the radio group
-onValue string
Required option. Value to store in the button's associated variable whenever this button is selected.
-relief ONE OF normal, half or none (default: normal)
Relief of the button.
-sensitive boolean (default: 1)
Whether or not the item is sensitive to user input.
-text percent-string (default: "")
Text or icon of the button.
-tooltip string
Message that appear next to this widget when the mouse pointer is held over it for a short amount of time.
-variable string (required option)
Name of a (global) variable which is changed when the state of the button changes. All radio buttons with the same variable are in one group. If the variable does not exist and the option -active is not set to 0, it is created and set to the value of the first button in the group. If the variable does exist and its value corresponds to the value of a button in this group, this button is selected. If the value of variable is set externally (e.g. via the set), the corresponding button in the group is selected and its associated command executed.
-visible boolean (default: 1)
Whether or not the item is visible.

Description

A radio button is like a checkbutton, but in a group of radio buttons only one can be selected. All radio buttons which use the same variable form a group. The value of the group is the value of the active radio button. The variable contains always the group value.

Commands

id cget option
Returns the value for one option. The option may have any of the values accepted by configure.
id configure [-option value...]
Configures the widget. Option may have any of the values accepted on creation of the widget.
id delete
Deletes the widget and the associated tcl command.
id onToggled
Executes the command given by the -onToggled option of the active item in the group.

Example

set box [gnocl::box \
    -orientation vertical]


$box add [gnocl::radioButton \
    -text "%__Cats" \
    -onValue cats \
    -variable animal \
    -onToggled {puts "%v == $animal"}]

$box add [gnocl::radioButton \
    -text "%__Dogs" \
    -onValue dogs \
    -variable animal \
    -onToggled {puts "%v == $animal"}]

$box add [gnocl::radioButton \
    -text "%__Birds" \
    -onValue birds \
    -variable animal \
    -onToggled {puts "%v == $animal"}]

gnocl::window \
    -title "Radio Buttons" \
    -child $box

results in



Comments