GRIDPLUS2 - Checkbutton Grid | ![]() |
||||||
|
GRIDPLUS Checkbutton Grid |
In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS checkbutton command mode. This command mode is a "short cut" method to invoke the GRIDPLUS widget command mode with the default widget set create checkbuttons. All of the normal widget command mode functionality can be used. For example creating other widget types.
This uses a simple syntax to create a grid of checkbuttons. The syntax is closely based on the GRIDPLUS Grid and Widget.
GRIDPLUS Checkbutton Specific Item Options/Functionality |
See GRIDPLUS Widget Grid for a full list of item options/functionality.
Invoking Commands When a Checkbutton is Selected |
There are two ways to specify commands to be invoked when a checkbutton is selected:-
Notes:
Example |
This section contains an example which illustrates the main GRIDPLUS checkbutton command mode features.
The following example assumes that the reader is familiar with the contents of the Grid/Layout and Widget pages. Information given on those pages will not be duplicated here.
Note: The example assumes that the GRIDPLUS package has already been "required" and the commands imported.
Window:
Source Code:
Comments:
When using the GRIDPLUS checkbutton command mode
the "label" defines the text that will appear as a label to the associated checkbutton. The cell
item begining with a dot is the widget (checkbutton) ID. The checkbuttons are created with names
based on the name of the containing Grid and the widget ID.
For example: The for the ".mygrid1" cell defined by "{"Label1" .1 +}"
a checkbutton widget is created with the name ".mygrid1,1". Please note that the
widget name does contain a comma - this is not a misprint!!
If a cell definition contains a plus sign (+)
the checkbutton will be in the "selected" state when created (By default checkbuttons are "deselected").
In ".mygrid2" the widget IDs are to the left of the label text. This will create
checkbuttons which are to the left of the label text.
In ".mygrid3" each cell definition contains only a widget ID or label text. In this
example a "matrix" of checkbuttons is created, each row and each column has one label. A
"null" cell definition is used to create an empty cell in the top left of the Grid. The widget
IDs have a :c suffix - This causes the
checkbuttons to be centred in the containing cell.
Checkbutton Example
gridplus checkbutton .mygrid1 -title "My Grid 1" {
{"Label1" .1 +} {"Label2" .2} {"Label3" .3}
{"Label4" .4} {"Label5" .5} {"Label6" .6}
{"Label7" .7} {"Label8" .8} {"Label9" .9 +}
}
gridplus checkbutton .mygrid2 -title "My Grid 2" {
{.1 "Option1"}
{.2 "Option2"}
{.3 "Option3"}
{.4 "Option4"}
}
gridplus checkbutton .mygrid3 -title "My Grid 3" {
{} {"Label A"} {"Label B"}
{"Label1"} {.1:c} {.2:c}
{"Label2"} {.3:c} {.4:c}
{"Label3"} {.5:c} {.6:c}
{"Label4"} {.7:c} {.8:c}
}
gridplus layout .main -wtitle "Checkbutton Example" {
.mygrid1:ew -
.mygrid2:ns .mygrid3:ew
}
pack .main
Reading and Setting GRIDPLUS Checkbutton Values |
The values of the GRIDPLUS widgets are stored in a global array with a null name.
For Example:
global {}
For GRIDPLUS checkbutton widgets the array element has the same name as the widget: Thus the value of ".1" in ".mygrid1" is referenced as "$(.mygrid1,1)".
The value will be either "0" (zero) when "deselected" or "1" when "selected".
The recommended method to set GRIDPLUS checkbutton values is to use the gpset command.
For Example:
gpset .mygrid1,2 1