Associating Callbacks to Tk-commands

Starting with version 3.0, STK callbacks are Scheme closures1. Apart scroll commands, callbacks are Schemes procedures without parameter. Suppose for example, that we want to associate a command with the previous .hello button. In Tcl, such a command can be expressed as $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr.hello configure -command {puts stdout "Hello, world"; destroy .}
In STK, we can write $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`

          gobblecr(.hello 'configure:command (lambda ()                                   (display "Hello, world\n")                                   (destroy *root*)))

When the user will press the mouse left button, the closure associated to the :command option will be evaluated in the global environment. Evaluation of the given closure will display the message and call the destroy Tk-command.

Note: ndexfile(index-entry "root window" "rm" main ) The root widget is denoted ``.'' in Tcl. This convention is ambiguous with the dotted pair convention and the dot must be quoted to avoid problems. Since this problem arises so often, the variable ndexfile(index-entry "*root*" "tt" aux )*root* has been introduced in STK to denote the Tk main window.



Subsections