GRIDPLUS2 - 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, dropdown, dateselector, entry, radiobutton, spinbox, 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, dropdown, dateselector, entry, radiobutton, spinbox 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
gridplus menu . {
Menu {
{Option1}
{Option2 .doit2 %mygroup1}
{Option3 %mygroup2}
}
}
spinbox .myspin -from 0 -to 10 -increment 1 -width 4 -textvariable (.myspin)
gridplus add .myspin -group mygroup2
gridplus entry .myentry -width 25 -title "Entry Fields" {
{"Field One" .field1}
{"Field Two" .field2 %mygroup1}
{"Field Three" .field3 %mygroup2}
{"Spin Box" @myspin}
}
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 -wtitle "Groups Example" {
.myentry .myradiobutton:ns
.mybutton:ew -
}
pack .main
gridplus menu . {
Menu {
{Option1}
{Option2 %mygroup1}
{Option3 %mygroup2}
}
}
spinbox .myspin -from 0 -to 10 -increment 1 -width 4 -textvariable (.myspin)
gridplus add .myspin -group mygroup2
gridplus entry .myentry -width 25 -title "Entry Fields" {
{"Field One" .field1}
{"Field Two" .field2 %mygroup1}
{"Field Three" .field3 %mygroup2}
{"Spin Box" @myspin}
}
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 -wtitle "Groups Example" {
.myentry .myradiobutton:ns
.mybutton:ew -
}
pack .main
...and...
Command: gridplus set -group mygroup2 -state disabled
Copyright © 2013 Adrian Davis.