GRIDPLUS2 - Radiobutton Grid | ![]() |
||||||
|
GRIDPLUS Radiobutton Grid |
In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS radiobutton command mode. This command mode is a "short cut" method to invoke the GRIDPLUS widget command mode with the default widget set create radiobuttons. 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 radiobuttons. The syntax is closely based on the GRIDPLUS Grid and Widget.
GRIDPLUS Radiobutton Specific Item Options/Functionality |
Invoking Commands When a Radiobutton is Selected |
There are two ways to specify commands to be invoked when a radiobutton is selected:-
Notes:
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 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 radiobutton command mode
the "label" defines the text that will appear as a label to the associated radiobutton. Although it is
possible to specify the names for each of the radiobutton widgets, knowing the names is not (generally)
useful. It is recommended that a dot only (".") be used to specify the position of the widget relative
to the text label. When a widget is not given a name GRIDPLUS will generate one automatically (based on
the name of the grid).
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 1
gridplus radiobutton .mygrid1 -title "My Grid 1" {
{"Label1" . +myval1} {"Label2" . -myval2} {"Label3" . -myval3}
{"Label4" . -myval4} {"Label5" . -myval5} {"Label6" . -myval6}
{"Label7" . -myval7} {"Label8" . -myval8} {"Label9" . -myval9}
}
gridplus radiobutton .mygrid2 -title "My Grid 2" {
{. "Option1" +myval1}
{. "Option2" -myval2}
{. "Option3" -myval3}
{. "Option4" -myval4}
}
gridplus radiobutton .mygrid3 -title "My Grid 3" {
{} {"Label A"} {"Label B"}
{"Label1"} {.:c +myval1A} {.:c -myval1B}
{"Label2"} {.:c -myval2A} {.:c -myval2B}
{"Label3"} {.:c -myval3A} {.:c -myval3B}
{"Label4"} {.:c -myval4A} {.:c -myval4B}
}
gridplus layout .main -wtitle "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 in the default group the array element has the same name as the radiobutton Grid: Thus the value of the ".mygrid1" radiobutton group is referenced as "$(.mygrid1)".
For radiobutton widgets that are part of a specified group the array element name is based on a combination of the name of the radiobutton Grid and the name of the group: Thus the value of a ".mygrid2" grid radiobutton in a group called "mygroup" is referenced as "$(.mygrid2,mygroup)".
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
...or...
gpset .mygrid2,mygroup myval3