Name
qbuttongroup — group buttons together
Syntax
qbuttongroup parent [ cmds ...]
Description
The qbuttongroup command creates a group that can have buttons assigned to it. After buttons have been assigned, the group's cmds will be called, no matter which button is activated. It is useful to have cmds to be a single call to a proc. The activated button is passed as argument to the proc.
The qbuttongroup itself is not a visible widget. It is only the buttons assigned to the group that is visible to the user. To achieve this use qtrace
See qtrace for a further description on how variable tracing works.
Arguments
parent
The parent widget.
cmds
One or more commands to be performed when one of the assigned buttons is pushed. The commands must be a string or a list, adhering to Tcl's syntax. A string may be either a single word or several words grouped as one string using quotes; a list is delimited by the '{' and '}' characters. Since the same command is used for all buttons, it is good practice to use a call to a proc - a callback function.
An action assigned for later execution is called a callback function. Since Tcl uses strings and lists to store commands, we will often use the term 'callback string' or 'callback list'.
Examples
Ex.1: QButtonGroup
proc group_a_callback { button } { qinformation "ButtonGroup A" "The number is [qtext $button]" } proc group_b_callback { button } { qinformation "ButtonGroup B" "You pushed [qtext $button]" } # Toplevel window set mywidget [qwidget ] qsetwindowtitle "ButtonGroup" qsetattribute deleteonclose qvboxlayout { # Create buttongroup and three buttons set group_a [qbuttongroup $mywidget group_a_callback] set a_one [qpushbutton "1"] set a_two [qpushbutton "2"] set a_three [qpushbutton "3"] qaddbutton $group_a $a_one qaddbutton $group_a $a_two qaddbutton $group_a $a_three qaddhboxlayout { # Create buttongroup and two buttons set group_b [qbuttongroup $mywidget group_b_callback] set ok [qpushbutton "Ok"] set cancel [qpushbutton "Cancel"] qaddbutton $group_b $ok qaddbutton $group_b $cancel } } # Make window visible qshow $w