GRIDPLUS - Using Groups
Home Reference Manpage Examples Download License Contact

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.


Groups Example

Window:

Source Code:

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

Comments:

package require combobox
namespace import combobox::*

Requires "combobox" package and imports the commands.
gridplus menu . {
   Menu {
      {Option1}
      {Option2 %mygroup1}
      {Option3 %mygroup2}
   }
}

Creates a menubar with one menu, which has three options. "Option2 is assigned to group "mygroup1" and "Option3 is assigned to group "mygroup2"
combobox .mycombo -textvariable (.mycombo)
eval .mycombo list insert end [list Option1 Option2 Option3]

Creates a combobox called ".mycombo". The value of the combobox selection is associated with the "null" array item "(.mycombo)", this allows the value os the combobox to be set using gpset. Three options are added to the dropdown list.
gridplus add .mycombo -group mygroup2

Assigns the ".mycombo" combobox to group "mygroup2".
gridplus entry .myentry -size 25 -title "Entry Fields" {
   {"Field One"   .field1}
   {"Field Two"   .field2 %mygroup1}
   {"Field Three" .field3 %mygroup2}
   {"Combo Box"   @mycombo}
}

Creates a GRIDPLUS Entry Grid with three entry fields. The ".mycombo" combobox is embedded in the Grid using the "@mycombo" option. "Field Two is assigned to group "mygroup1" and "Field Three is assigned to group "mygroup2"
gridplus radiobutton .myradiobutton -group mygroup1 -title "Radiobuttons" {
   {.rbutton1 "Option One"   +opt1}
   {.rbutton2 "Option Two"   -opt2}
   {.rbutton3 "Option Three" -opt3}
}

Creates a GRIDPLUS Radiobutton Grid with three radiobuttons. The -group option assigns all three radiobuttons to group "mygroup1".
gridplus button .mybutton {
   {"Button 1" .button1} {"Button 2" .button2 %mygroup1} {"Button 3" .button3 %mygroup2}
}

Creates a GRIDPLUS Button Grid with three buttons. "Button 2 is assigned to group "mygroup1" and "Button 3 is assigned to group "mygroup2"
gridplus layout .main -title "Groups Example" {
   .myentry     .myradiobutton:ns
   .mybutton:ew -
}

pack .main

Creates a GRIDPLUS layout called ".main" to arrange the widgets in the window, and uses "pack" to display the layout.

Usage:

Command: gridplus set -group mygroup1 -state disabled

Result:-

Command: gridplus set -group mygroup2 -state disabled

Result:-

Command: gridplus set -group mygroup1 -state disabled
...and...
Command: gridplus set -group mygroup2 -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


Copyright © 2004 Adrian Davis.