Updated 2008-02-20 20:50:19 by escargo

Purpose: Brief intro to Tk

Tk is a Tcl extension, written in C, designed to give the user a relatively high level interface to his or her windowing environment. You can find the source code for Tk at http://sourceforge.net/projects/tktoolkit/ .

On a Macintosh, Tk provides interfaces to the MacOS windowing system. On Microsoft Windows 95/98/NT/2000/2003/XP/Vista/..., Tk provides interfaces to the Microsoft windowing system. On the other platforms where Tk is available, Tk provides interfaces to the X window system using a Tk specific look and feel, designed initially to look uniquely Tk, then, in Tk 8.[0-4], updated to look very similar to Motif, but not using the Motif libraries.

Tk was written by John Ousterhout, the creator of Tcl. A PostScript version of the paper introducing Tk to the world can be found at ftp://www.tcl.tk/pub/tcl/doc/tkUsenix91.ps . The PostScript for slides used by Dr. Ousterhout during various USENIX tutorials can be found at ftp://www.tcl.tk/pub/tcl/doc/tut.tar.Z .

Tk allows you to create, manage, and manipulate widgets, rectangular areas on the screen with various features, from which you can build quite powerful GUIs with little effort. Widget classes:

  • button (with text or image): executes a command when clicked
  • label (with text or image): can be updated from a variable
  • text widget: holds text in various fonts, colors, styles; can also hold embedded images and widgets; can wrap and/or be scrolled
  • canvas: holds graphic objects (including text, images, widgets)
  • listbox: holds text lines from which to select
  • scrollbar: controls the display within another widget through the slider and the 2 arrows at each end.
  • slider: horizontal or vertical, allows setting a numeric value

For sample images, look at Widgets in the initial Tk package.


On the titular theme, "Tk" occasionally labels each of

  • the Tk language, which extends Tcl (that is, is a proper superset)
  • the Tk library, which is available for applications built in such languages as C, Perl, and so on
  • the wish interpreter which instantiates a Tk console
  • ...


See Beginning Tk for more information.


There are many online Tcl and Tk tutorials, perhaps starting with an overview of tcl and tk; Tcl Tutor is quite popular as a desktop computer aided instruction application.


Also of interest might be Alternate toolkit bindings, Common Tk Error Messages and Possible Explanations, Alternate widget sets


See What is Tcl for information about the initial language that formed a basis for Tk.


DO NOT CLICK THIS LINK. It is a trap for badly behaved bots. If you follow this link, you will be unable to use the site afterwards.