[HOME][CONTENTS][DOWNLOAD][PREV][NEXT]


COMB WIDGET EXAMPLES

Grouped Buttons. Grouped buttons (gbtn) are a comb-widget for a group of buttons. Both radio button and check button are supported. A gbtn widget hosts a group of buttons in a frame that may be packed together with other widgets. The frame is provided with a configurable text label to be used as a title of the button group. 

EXAMPLE: The following example creates a gbtn widget that contains two radiobuttons and three checkbuttons. 

catch "destroy .g"
toplevel .g
wm title .g "gbtn"
global radio
set radio 1
pack [gbtn.create .g.gbtn \
    -label {-text {Group}} -btns { \
    {radio -text {Button0} -val 0 -var radio -comm {puts radio0}} \
    {radio -text {Button1} -val 1 -var radio -comm {puts radio1}} \
    {check -text {Button2} -var b2 -comm {puts Button2:b2}} \
    {check -text {Button3} -var b3 -comm {puts Button3:b3}} \
    {check -text {Button4} -var b4 -comm {puts Button4:b4}} } \
    -layout vertical] -expand 1 -fill both 

A gbtn widget with two radio buttons
and three check buttons 

CLASS NAME: gbtn

COMB-WIDGET OPTIONS

-label options   It specifies options for a sub-widget of Label to display a text lable of the button group at the top of the frame. 
-btns buttonDefList   It specifies a list of button widget definitions. It is only used for gbtn.create. A button widget definition is a list of two elements. The first element is the button type, i.e., radio, or check. The second element is a list of options for that button. A value of radio defines that the following options are for a Radiobutton. A value of check defines that the following options are for a Checkbutton. 
-btn0, -btn1, ..., -btnn   These refer to sub-widgets created by the command gbtn.create and are available only after the widget has been created. A sub-widget referred to by a -btni (i=0, 1, ..., n) can be either a Radiobutton or a Checkbutton as specified in the option of -btns by either a radio or a check. The GUI of these buttons depend on the specified option of -btns and configurations by the command gbtn.config
-layout layoutOption   It specifies a value of -side option for packing the sub-widgets. It is only used in the widget creation. The allowed values for the -layout are vertical and horizontal. A vertical value of the -layout packs the buttons from thhe top side. A horizontal value of the -layout packs the buttons from the left side. 
-pad padOption   It specifies a value to define the internal size that a gbtn widget uses as pad between the buttons and the outer frame. The default is 4. 
WIDGET API
gbtn.bind pathname event scripts -varName. This command binds the event of the sub-widget referred to by the -varName to the scripts. TThe pathname must refer to a gbtn widget. If the event is not specified, the current event that was bound to the sub-widget is returned. If the scripts is not specified, the current scripts bound to the event is returned. The scripts may be appended to the current ones if "+scripts" is specified instead of "scripts". If the -varName is not specified, the command bindpathname event scripts is invoked. 
gbtn.cget pathname -varName. This command retrieves the value of the -varName for a gbtn widget. The pathname must refer to a gbtn widget. The available -varNames are: -label, -btn0, -btn1, .., and -btnn
gbtn.config pathname ?options?. This command configures options of a gbtn widget referred to by the pathname. If the ?options? is not specified, a list of the gbtn widget configuration is returned. Each element of the list is a list that provides information of a configurable option. The first element of a configurable option list is always the -varName. The rest of the contents depend on what the -varName refers to. If the -varName refers to a regular variable, the second element that is also the last element is the value for that variable. If the -varName refers to a sub-widget, the second element is the pathname of the sub-widget, the third is the class name, and the fourth that is also the last is the options used in previous widget creation or configuraiton. 
gbtn.create pathname ?options?. This command creates a gbtn widget with the given options. If the gbtn widget is successfully created, the pathname is returned. Otherwise, an empty string is returned. The available options for a gbtn.create command are: -label, -layout, and -btns
RELATED PROCEDURES

The followings are procedures used in a gbtn widget implementation and test. A user may access to these procedures through the gbtn widget API, and should never use these procedures directly in an application program. 

gbtn.frame pathname
gbtn.free pathname.
gbtn.test pathname layout

[HOME][CONTENTS][DOWNLOAD] 1