Main Content

Tcl + Tk (Wish) - an introduction and revision example

Archive - Originally posted on "The Horse's Mouth" - 2013-11-15 13:48:18 - Graham Ellis

Whenever I teach Tcl with Tk, I'm delighted to be reminded how easy it is to put together a graphic user interface (GUI) with Tcl. They may not be the world's prettiest, but they're quick, straightforward and functional. And so it was on the final day of our Tcl Programming course last week, when I did just half an hour on Tk and wish.

* At the start of your code, define procedures that are to be performed when buttons are pressed or data is entered in some other way

* Define the components of your GUI, including a note of which function each is linked to

* Define the layout - how the components are drawn in relationship to each other and to the window in which they appear

... and that can be about it!

The example shown here is three concurrent runs of a GUI with a simple increment / decrement counter that's also changing the colour of the targeted label on the interface. A simple but effective demonstration.

Full source code is [here].