ClassyTcl

  ClassyTk menu definition

Home    Documentation    Screenshots    Binary distributions    Source distribution   

The contents of the menus managed by DynaMenu in ClassyTk are determined by a menu definition. Which definition is used for a type of menu is determined in the the configuration system.

A menu definition consists of a number of lines. Each line specifies one menu item, and starts with a word describing the type of item. The rest of the line contains a list of parameters. If a parameter contains spaces, it must be surrounded with curly braces ({}) or double quotes (""). A parameter enclosed in curly braces can also span multiple lines. A line can be commented out by starting with a hash character (#). It is possible to create hierarchical menus with the type menu that will create submenus The following menu item types are supported:

menu

This creates a submenu. It has the following parameters:
  1. Text: This text will be displayed in the menu item
  2. Definition: The definition of what is in the submenu: This takes the same format as the main menu

action

This creates a menu item from which a command can be invoked. It has the following parameters:
  1. Text: This text will be displayed in the menu item
  2. command: This command will be executed when the item is invoked. Each menu has an attached cmdw (commmand window) where actions invoked from the menu will take place. If the command contains %W it will be replaced with the cmdw of the current menu. This can be necessary if one menu definition is used for several menus, eg. a number of editor windows, where each menu should invoke commands on the editor widget in the same window.
  3. ?short-cut?: optional key short-cut that can be used to invoke this menu item from the cmdw. It can either be a Tcl key event (eg. <Up>, <Alt-a>, <F2>) or a virtual event (eg. <<Up>>, <<Print>>).
A typical example would be:
action "Save" {filesave %W} <<Save>>

separator

This tool takes no parameters, and just creates a separator in a menu.

check

check creates a check entry. This is typically used to change a variable to an on or off value. It can also execute a command. It has the following parameters:
  1. text: This text will be displayed in the menu item
  2. options: A number of options as can be given when configuring the Tcl checkbutton. %W will be replaced by the name of the cmdw of the current toolbar.
  3. ?short-cut?: optional key short-cut.
A typical example would be:
check "Checked" {-variable checked -command {puts %W:$checked}}

radio

radio creates a radio entry. This is typically used to change a variable to one of several values. It can also execute a command. It has the following parameters:
  1. text: This text will be displayed in the menu item
  2. options: A number of options as can be given when configuring the Tcl
  3. ?short-cut?: optional key short-cut. radiobutton. %W will be replaced by the name of the cmdw of the current toolbar.
A typical example would be:
radio "opt1" {-variable opt -value opt1 -command {puts %W:$opt}}
radio "opt2" {-variable opt -value opt2 -command {puts %W:$opt}}

activemenu

This creates a submenu that can be changed upon each invocation. It has the following parameters:
  • Text: This text will be displayed in the menu item
  • command: This command will be executed upon each invocation of the menu. The command should return a menu definition describing the submenu that should be displayed.
  • ?short-cut?: optional key short-cut.
    Peter De Rijk
    hosted at SourceForge.net Logo