GRIDPLUS - Radiobutton Grid | ![]() |
||||||
|
GRIDPLUS Radiobutton Grid |
In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS radiobutton command mode. This uses a simple syntax to create a grid of checkbuttons. The syntax is closely based on the GRIDPLUS Grid.
GRIDPLUS Radiobutton Item Options |
Example |
This section contains an example which illustrates the main GRIDPLUS radiobutton command mode features.
The following example assumes that the reader is familiar with the contents of the Grid/Layout page. Information given on that page 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 radiobutton command mode
the "label" defines the text that will appear as a label to the associated radiobutton. The cell
item begining with a dot is the widget (radiobutton) ID. The radiobuttons 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 "{"Label2" .2 +myval2}"
a radiobutton widget is created with the name ".mygrid1,2". Please note that the
widget name does contain a comma - this is not a misprint!!
The cell definition must also specify the value the radiobutton group will have when the
associated radiobutton is "selected". A string with a "+" (Selected) or "-"
(Deselected) prefix is used to indicate the value. If more than one "selected" value is specified
for a radiobutton group the last one will take effect.
In ".mygrid2" the widget IDs are to the left of the label text. This will create
radiobuttons 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 radiobuttons 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
radiobuttons to be centred in the containing cell.
Radiobutton Example
gridplus radiobutton .mygrid1 -title "My Grid 1" {
{"Label1" .1 +myval1} {"Label2" .2 -myval2} {"Label3" .3 -myval3}
{"Label4" .4 -myval4} {"Label5" .5 -myval5} {"Label6" .6 -myval6}
{"Label7" .7 -myval7} {"Label8" .8 -myval8} {"Label9" .9 -myval9}
}
gridplus radiobutton .mygrid2 -title "My Grid 2" {
{.1 "Option1" +myval1}
{.2 "Option2" -myval2}
{.3 "Option3" -myval3}
{.4 "Option4" -myval4}
}
gridplus radiobutton .mygrid3 -title "My Grid 3" {
{} {"Label A"} {"Label B"}
{"Label1"} {.1:c +myval1A} {.2:c -myval1B}
{"Label2"} {.3:c -myval2A} {.4:c -myval2B}
{"Label3"} {.5:c -myval3A} {.6:c -myval3B}
{"Label4"} {.7:c -myval4A} {.8:c -myval4B}
}
gridplus layout .main -title "Radiobutton Example" {
.mygrid1:ew -
.mygrid2:ns .mygrid3:ew
}
pack .main
Reading and Setting GRIDPLUS Radiobutton Values |
The values of the GRIDPLUS widgets are stored in a global array with a null name.
For Example:
global {}
For GRIDPLUS radiobutton widgets the array element has the same name as the radiobutton Grid: Thus the value of the ".mygrid1" radiobutton group is referenced as "$(.mygrid1)".
The value will be that specified for the currently selected radiobutton. If no button is selected the value will be null.
The recommended method to set GRIDPLUS radiobutton values is to use the gpset command.
For Example:
gpset .mygrid1 myval2