Tk (software)

Tk is an open, free and cross-platform toolkit for programming graphical user interfaces (GUIs ), which is well suited for " quick and dirty" programming and prototyping, but also for the creation of small to medium programs for Unix ( X ), Windows ( from 95 ) and Macintosh. The kit was developed ( Tool Command Language) for Tcl and from there is easy to use. Since it is proven, Python ( Tkinter ), Ruby, Common Lisp and R were, among others, also for Perl, developed connections so that it also serves these programming as graphical toolkit. Tk is released as free software under a BSD- style license.


Tk provides the following UI elements:

  • Button
  • Canvas
  • CheckButton
  • Combobox ( 8.5)
  • Entry
  • Frame
  • Label
  • Label frame
  • Listbox
  • Menubutton
  • Message
  • Notebook (8.5)
  • Panedwindow
  • Progressbar (8.5)
  • Radiobutton
  • Scale
  • Scrollbar
  • Separator (8.5)
  • Size grip ( 8.5)
  • SpinBox
  • Tk_optionMenu
  • Treeview (8.5)
  • Text

Furthermore, the following top-level windows are available

  • Tk_chooseColor - color selection
  • Tk_chooseDirectory - folder selection
  • Tk_dialog - Modal dialog
  • Tk_getOpenFile - file- selection
  • Tk_messageBox - Notes Box
  • Toplevel - General toplevel window

Geometry Manager

The geometry manager ( in Java they are called layout managers ) of Tk pack, grid and place. The differences between the geometry manager:

More complex layouts can be achieved by using ( nested ) frames. In each frame, only one of the geometry managers may be used within an application but can certainly all three occur.

The fact that Tcl can handle very well with Unicode ( even this standard does), and international characters in Tk applications it is very easy to visualize.

From the versions of Tcl / Tk 8 ' native look and feel' offered, namely Macintosh applications sits the menu bar always on top of the screen to Windows and Unix, however, at the top of each application window. Other widgets see each look like one is used on the different platforms.

Tk is contained generally in the delivery of Tcl / Tk and is freely available. There is plenty of additional software, see also articles on Tcl. In most Linux distributions, it is available for Windows and Mac, you can upload it for free from the Internet, also known as binary version, ie you do not need even to translate. This is especially important for Windows and Mac, because many users have installed there no compiler.


A minimal drawing program in Tcl: use a canvas widget c, can be subscribed to by the mouse.. For this purpose, "bindings ", " hold down the left mouse button" for the events and " down movement with left mouse button" agreed. The procedure doodle provides these links here:

Doodle proc {w {color black} } {      bind $ w < 1> [list doodle'start % W % x % y $ color]      bind $ w { doodle'move % W % x % y}   } When left-clicking a line object (whose start and end points still coincide ) is applied:

Proc w x y doodle'start { color} {      set :: _id [ $ w create line $ x $ y $ x $ y -fill $ color]   } When the mouse moves the current line object is extended a distance:

Proc w x y doodle'move { } {      $ w coords $ :: _id [ concat [ $ w coords $ :: _id ] $ x $ y]   } The main program is just three lines long:

Package require Tk   pack [canvas. c- bg white ] -fill both- expand 1   doodle. c   bind. c {% W delete all} The last statement defines that if you double click the right mouse button, the drawing is erased.


  • GUI framework
  • Tcl
  • Free system software