GRIDPLUS - Checkbutton Grid
Home Reference Manpage Examples Download License Contact

GRIDPLUS Checkbutton Grid

In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS checkbutton command mode. This uses a simple syntax to create a grid of checkbuttons. The syntax is closely based on the GRIDPLUS Grid.

GRIDPLUS Checkbutton Item Options

The name of the checkbutton (Example: .b1).

The name of the group to which checkbutton belongs (Example: %mygroup1).

Insert specfied grid/layout/widget (Example: @myoptions).

Specifies that the checkbutton should be created in selected mode.

Specifies that the checkbutton should be created in deselected mode (Default).


This section contains an example which illustrates the main GRIDPLUS checkbutton 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.

Checkbutton Example


Source Code:

gridplus checkbutton .mygrid1 -title "My Grid 1" {
  {"Label1" .1 +} {"Label2" .2} {"Label3" .3}
  {"Label4" .4}   {"Label5" .5} {"Label6" .6}
  {"Label7" .7}   {"Label8" .8} {"Label9" .9 +}

gridplus checkbutton .mygrid2 -title "My Grid 2" {
  {.1 "Option1"}
  {.2 "Option2"}
  {.3 "Option3"}
  {.4 "Option4"}

gridplus checkbutton .mygrid3 -title "My Grid 3" {
  {}         {"Label A"} {"Label B"}
  {"Label1"} {.1:c}      {.2:c}
  {"Label2"} {.3:c}      {.4:c}
  {"Label3"} {.5:c}      {.6:c}
  {"Label4"} {.7:c}      {.8:c}

gridplus layout .main -title "Checkbutton Example" {
   .mygrid1:ew  -
   .mygrid2:ns  .mygrid3:ew

pack .main


When using the GRIDPLUS checkbutton command mode the "label" defines the text that will appear as a label to the associated checkbutton. The cell item begining with a dot is the widget (checkbutton) ID. The checkbuttons 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 "{"Label1" .1 +}" a checkbutton widget is created with the name ".mygrid1,1". Please note that the widget name does contain a comma - this is not a misprint!!

If a cell definition contains a plus sign (+) the checkbutton will be in the "selected" state when created (By default checkbuttons are "deselected").

In ".mygrid2" the widget IDs are to the left of the label text. This will create checkbuttons 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 checkbuttons 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 checkbuttons to be centred in the containing cell.

Reading and Setting GRIDPLUS Checkbutton Values

The values of the GRIDPLUS widgets are stored in a global array with a null name.

For Example:

global {}

For GRIDPLUS checkbutton widgets the array element has the same name as the widget: Thus the value of ".1" in ".mygrid1" is referenced as "$(.mygrid,1)".

The value will be either "0" (zero) when "deselected" or "1" when "selected".

The recommended method to set GRIDPLUS checkbutton values is to use the gpset command.

For Example:

gpset .mygrid1,2 1

Copyright © 2004 Adrian Davis.