Associating Callbacks to Tk-commands

Starting with version 3.0, callbacks are Scheme closures[*]. 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
\begin{scheme}
.hello configure -command \{puts stdout ''Hello, world''; destroy .\}
\end{scheme}
In , we can write
\begin{scheme}
(.hello 'configure{\bf :command} (lambda ()
(display ''Hello, world\backwhack{}n'')
(destroy *root*)))
\end{scheme}

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.


\begin{note}
\mainindex{root window}
The root widget is denoted \lq\lq .'' in Tcl. Th...
...e{*root*} has been introduced in
{\stk} to denote the Tk main window.
\end{note}



Subsections