Version 15 of What is Tk

Updated 2003-07-18 13:32:28

Purpose: Brief intro to Tk

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

On a Macintosh, Tk provides some interfaces to the MacOS windowing system. On Microsoft Windows 95/98/NT/2000, Tk provides some interfaces to the Microsoft windowing system. On Unix and other platforms where Tk is available, Tk provides some interfaces to the X window system using a Tk specific look and feel, designed 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
  • slider: horizontal or vertical, allows setting a numeric value

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


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


Tk syntax help - Arts and crafts of Tcl-Tk programming