Documentation‎ > ‎Menus‎ > ‎

    gnocl::menuRadioItem

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

    Synopsis

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

    Screenshot

    Options

    -accelerator
    type: string
    Accelerator for this item, like "<Ctrl>A" or "<Shift><Alt>B".
    -active
    type: boolean (default: 0)
    Whether the widget is active. This overrides the value of the associated variable. If set to 1, the associated variable is set accordingly.
    -data
    type: string
    User defined data which can be retrieved via the cget subcommand.
    -inconsistent
    type: boolean (default: 0)
    Whether the widget state is rendered inconsistent, for example if multiple items in an application are selected which do not have all the same state.
    -name
    type: string
    Name of the widget, can be used to set options in an rc file.
    -onToggled
    type: 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
    -sensitive
    type: boolean (default: 1)
    Whether or not the item is sensitve to user input.
    -text
    type: percent-string (default: "")
    Text or icon of the button
    -tooltip
    type: string
    Message that appear next to this widget when the mouse pointer is held over it for a short amount of time.
    -value
    type: string
    (Required option) Value to store in the button's associated variable whenever this button is selected.
    -variable
    type: string    Required option.
    Name of a (global) variable which is changed when the state of the item changes. All radio items 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 item 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
    type: boolean (default: 1)
    Whether or not the item is visible.

    Description

    A radio item is like a check item, but in a group of radio items only one can be selected. All radio items of one group share one variable. This variable contains always the value of the active radio item.

    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 animal dog

    set menu [gnocl::menu \
        -title "menuRadioItem"]

    $menu add [gnocl::menuRadioItem \
        -text "%_Has _Bird" \
        -variable animal \
        -onValue bird]

    $menu add [gnocl::menuRadioItem \
        -text "%_Has _Dog" \
        -variable animal \
        -onValue dog]

    $menu add [gnocl::menuRadioItem \
        -text "%_Has _Cat" \
        -variable animal \
        -onValue cat]

    $menu popup

    results in



    Comments

    Sections