Home Reference Manpage Examples Download License Contact


In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS menu command mode. This uses a simple syntax to create a menubar and cascaded menus.

If the name parameter supplied to the a menu command mode identifies a toplevel window a menubar is created, otherwise a "named" (cascadable) menu is created.

GRIDPLUS Menu Layout

The menu layout defines a list of menu options. The layout list consists of pairs of items, which can have either of the following formats:-

GRIDPLUS Menu Item Options

The name of the command to be invoked (Optional).

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

Create widget with disabled state. Overrides -state option.

Create widget with normal state. Overrides -state option.

Specifies that entry validations are to be perfomed (for the window containing the menu) prior to evaluating the command.

Specifies that a separator line is displayed.

Specifies menu name will cascade from this entry (Example: @mymenu).


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

Menu Example


Width "Menu1" selected...

Source Code:

gridplus menu .mymenu {
   ~ {"Cascade Option 1"}
   ~ {"Cascade Option 2" .mycascade2}

gridplus menu . {
   Menu1 {

   Menu2 {
      {Option3 .myoption3}
      {Option4 .myoption4}

   Menu3 {
      {"Option Five"}
      {"Option Six" @mymenu}
      {"Option Seven"}

   ~ {"Menu4" .menu_four}

gridplus grid .text -pad 25 -relief groove {
   {"^This is a Window with a four option menubar"}

gridplus layout .main -title "Menu Example" {

pack .main


When using the GRIDPLUS menu command mode each Menu consists of a menu name followed by a list of menu options.

By default, When a menu option is selected a command is invoked which as a name based on the name of the menubar, the menu name and the option label text. The menu name and the option label text are converted to lowercase and spaces are replaced by underscores.

For Example: When "Option Six" is select from "Menu3", the name of the command invoked will be "menubar:menu3,option_six".

It is also possible to invoke a specific command by specifying a dot prefixed command name.

For Example: When "Option3" is select from "Menu2", the name of the command invoked will be "myoption3".

"Menu3" demontrates that menu option labels containg spaces must be enclosed in quotes.

Specifying a dash ("-") instead of a menu option displays a dividing line in the menu:-

Copyright © 2004 Adrian Davis.