| GRIDPLUS - Using Groups | ![]() |
||||||
|
| GRIDPLUS Groups |
The GRIDPLUS "Groups" facility provides a method to set the state (normal/disabled) for a named Group of widgets -or- menu options, with a single command.
The button, checkbutton, entry, radiobutton, tablelist and text GRIDPLUS command modes have a -group option to assign all widgets created using the command mode with a particular Group.
The button, checkbutton, entry, radiobutton, and menu command modes also support the % widget option which allows individual widgets within a Grid -or- menu options, to be assigned to the particular Group.
Other (Non-GRIDPLUS) TCL/TK widgets, which support a -state option, can also be assigned to a Group using the GRIDPLUS add command mode.
| Example |
This section contains an example which illustrates the main GRIDPLUS Groups facility 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:
Usage:
Command: gridplus set -group mygroup1 -state disabled
Result:-
Command: gridplus set -group mygroup2 -state disabled
Result:-
Command: gridplus set -group mygroup1 -state disabled
Result:-
Note: To set a group to the enabled state the "-state normal" option
may be used.
For Example:
gridplus set -group mygroup2 -state normal
Groups Example
package require combobox
namespace import combobox::*
gridplus menu . {
Menu {
{Option1}
{Option2 .doit2 %mygroup1}
{Option3 %mygroup2}
}
}
combobox .mycombo -textvariable (.mycombo)
eval .mycombo list insert end [list Option1 Option2 Option3]
gridplus add .mycombo -group mygroup2
gridplus entry .myentry -size 25 -title "Entry Fields" {
{"Field One" .field1}
{"Field Two" .field2 %mygroup1}
{"Field Three" .field3 %mygroup2}
{"Combo Box" @mycombo}
}
gridplus radiobutton .myradiobutton -group mygroup1 -title "Radiobuttons" {
{.rbutton1 "Option One" +opt1}
{.rbutton2 "Option Two" -opt2}
{.rbutton3 "Option Three" -opt3}
}
gridplus button .mybutton {
{"Button 1" .button1} {"Button 2" .button2 %mygroup1} {"Button 3" .button3 %mygroup2}
}
gridplus layout .main -title "Groups Example" {
.myentry .myradiobutton:ns
.mybutton:ew -
}
pack .main
package require combobox
namespace import combobox::*
gridplus menu . {
Menu {
{Option1}
{Option2 %mygroup1}
{Option3 %mygroup2}
}
}
combobox .mycombo -textvariable (.mycombo)
eval .mycombo list insert end [list Option1 Option2 Option3]
gridplus add .mycombo -group mygroup2
gridplus entry .myentry -size 25 -title "Entry Fields" {
{"Field One" .field1}
{"Field Two" .field2 %mygroup1}
{"Field Three" .field3 %mygroup2}
{"Combo Box" @mycombo}
}
gridplus radiobutton .myradiobutton -group mygroup1 -title "Radiobuttons" {
{.rbutton1 "Option One" +opt1}
{.rbutton2 "Option Two" -opt2}
{.rbutton3 "Option Three" -opt3}
}
gridplus button .mybutton {
{"Button 1" .button1} {"Button 2" .button2 %mygroup1} {"Button 3" .button3 %mygroup2}
}
gridplus layout .main -title "Groups Example" {
.myentry .myradiobutton:ns
.mybutton:ew -
}
pack .main
...and...
Command: gridplus set -group mygroup2 -state disabled
Copyright © 2004 Adrian Davis.