next up previous contents
Next: EntryInt, Float Up: Element on a configuration page Previous: ComboBox

Command

 

tex2html_wrap1063


A Command widget is a widget, which when selected will invoke a tcl function. This function may bring up a color palete, as in the demo module, or anything else the dotdotfile programmer wishes. The button, which the user can press, may be configured by the dotdotfile programer. This way e.g. the color or the font of the button can be changed. The only restriction on the function is that it doesn't return before the user is finished with it (E.g. has selected a color), and that the function return the new value for the element.

The command also have to take local grab, to avoid that the page, which the element comes from is changed. This is done with the commands pushGrab and popGrab. popGrab doesn't take any arguments, while pushGrab takes two command, the first should be ``local'', and the second should be the name of the toplevel window.

Standard Options

-text
This is the text before the button
-textafter
This is the text after the button.
-help
This is help for the element.
-default
This is the default value for the element.
-setvalue
This is a command, which is called by the Dotfile Generator, whenever it needs to set the widget.
-invoke
This is the command of the widget (e.g. the function to create the color scale.
-enable
This is the function to evaluate, when the element is enabled
-disable
This is the function to evaluate, when the element is disabled.
-inactive
This is a function similar to -setvalue, except that it may not refer to any variable! It is called when a Command widget is mapped inside an ExtEntry, and the tuple is not yet initialized with a value.
-export
This tells wether the widget shall be exported or not.

In the -setvalue, -invoke, -disable and -enable functions, the command button may be refered to as $widget

Link to Variables

The Command widget will link to a variable with the same name as the element. Please remember that the value will only be set/read of you, so if you need some internal status, you may comunicate a list as the value of the element.

example

This example is from the demo module.

  Command color \
      -text "Foreground color" \
      -default [list #FF00A4 0] \
      -setvalue {$widget configure -bg [lindex $color 0] -text "      "} \
      -invoke {makeScale $colorList [lindex $color 0] [lindex $color 1]} \
      -disable {$widget configure -bg \#000000 -text ""} \
      -enable {$widget configure -bg [lindex $color 0] -text "      "} \
      -help "This is an example of the command widget."

Please note the following points:

The save function may look something like this:

  Save {
    print "The color selected is [lindex $color 0]"
  }

Please note that the second value (the greyscaled flag) isn't used in the save function, only the actual color.


next up previous contents
Next: EntryInt, Float Up: Element on a configuration page Previous: ComboBox

Jesper Kjær Pedersen <blackie@imada.ou.dk>
Wed Oct 2 13:29:53 MET DST 1996