Tk (software)

Last updated

Original author(s) John Ousterhout
Developer(s) Tcl Core Team [1]
Initial release1991;32 years ago (1991)
Stable release
8.6.13 [2]   OOjs UI icon edit-ltr-progressive.svg / 22 November 2022
Written in C
Operating system Cross-platform
Platform Cross-platform
Type Widget toolkit
License BSD-style [3]

Tk is a cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface (GUI) in many programming languages. It is free and open-source software released under a BSD-style software license.


Tk provides many widgets commonly needed to develop desktop applications, such as button, menu, canvas, text, frame, label, etc. Tk has been ported to run on most flavors of Linux, macOS, Unix, and Microsoft Windows. Like Tcl, Tk supports Unicode within the Basic Multilingual Plane, but it has not yet been extended to handle the current extended full Unicode (e.g., UTF-16 from UCS-2 that Tk supports).

Tk was designed to be extended, and a wide range of extensions are available that offer new widgets or other capabilities. [4] [5]

Since Tcl/Tk 8, it offers "native look and feel" (for instance, menus and buttons are displayed in the manner of "native" software for any given platform). [6] Highlights of version 8.5 include a new theming engine, originally called Tk Tile, [7] but it is now generally referred to as "themed Tk", as well as improved font rendering. [8] Highlights of version 8.6 include PNG support and angled text. [9]


Tk was developed by John Ousterhout as an extension for the Tcl scripting language. It was first publicly released in 1991. [10] Tk versioning was done separately from Tcl until version 8.0.

Tk was written originally for Unix/X11, and proved extremely popular with programmers in the 1990s by virtue of its being easier to learn and use than Motif and other X11 toolkits of the time. [11] Tk was also ported to Microsoft Windows and Macintosh platforms, starting with Tk 4.2 and improved with native look and feel in Tk 8.0 (released 1997). To mark the popularity and significance of Tk in the 1990s, Ousterhout was given the ACM Software System Award in 1997 for Tcl/Tk: [12]

ACM Software System Award Winner: John K Ousterhout

For the Tcl scripting language which allows developers to create complex systems from pre-existing components. The embedded Tk provides a simple mechanism for creating graphical user interfaces. Together they make a powerful addition to the software repertoire.

Interest in Tk waned significantly from the late 1990s and onward. The default look and feel on Unix still emulated Motif, despite the mainstream replacement of Motif by toolkits such as FLTK, Qt, and GTK. [13] Widgets that became commonly used in applications (e.g. trees, combo boxes, tabbed notebooks) were not available in the Tk core, but only via multiple, often competing add-ons. [14]

Tk 8.5, released in late 2007, corrected some of these problems by adding missing widgets to the core, introducing a new theming engine and modernizing the look and feel on Unix. [8] However, because some code changes were required to incorporate these advancements, many existing applications retain the older Motif-inspired feel that Tk had become known for. [15]


Tk is a platform-independent GUI framework developed for Tcl. From a Tcl shell (tclsh), Tk may be invoked using the command package require Tk. The program wish (WIndowing SHell) provides a way to run a tclsh shell in a graphical window as well as providing Tk. [16]

Tk has the following characteristics:

Language bindings

A library written in one programming language may be used in another language if bindings are written; Tk is integrated with the Tcl language. Various other languages have bindings for Tk, a partial list of which is on the Tk website. [20] Bindings exist for additional languages which might not be listed, including Ada (called TASH), [21] Haskell (called HTk), [22] Perl, Python (called Tkinter), R (through the standard package: tcltk), Ruby, Rexx, and Common Lisp.

There are several ways to use Tk from Perl: the Tcl::Tk and Tkx Perl modules, [23] both of which use Tcl as a bridge to access Tk, and Perl/Tk, [24] which provides native Perl access to Tk structures. The Python binding uses Tcl as a bridge to Tk. [25]


Tk provides various widgets. [26] Basic widgets are embedded into toplevel widgets, which in turn are usually hosted by the operating system in floating windows that can be moved around on the screen. [27]

Basic widgets

  • button
  • canvas
  • checkbutton
  • combobox
  • entry
  • frame
  • label
  • labelframe
  • listbox
  • menu
  • menubutton
  • message
  • notebook
  • panedwindow
  • progressbar
  • radiobutton
  • scale
  • scrollbar
  • separator
  • sizegrip
  • spinbox
  • text
  • tk_optionMenu
  • treeview

Top-level widgets

Geometry managers

Basic widgets are arranged in toplevel windows using geometry managers: [28]

See also

Related Research Articles

An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools, and a debugger. Some IDEs, such as NetBeans and Eclipse, contain the necessary compiler, interpreter, or both; others, such as SharpDevelop and Lazarus, do not.

<span class="mw-page-title-main">Shell script</span> Script written for the shell, or command line interpreter, of an operating system

A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script which sets up the environment, runs the program, and does any necessary cleanup or logging, is called a wrapper.

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

<span class="mw-page-title-main">Windows Script Host</span> Automation Technology for Windows

The Microsoft Windows Script Host (WSH) is an automation technology for Microsoft Windows operating systems that provides scripting abilities comparable to batch files, but with a wider range of supported features. This tool was first provided on Windows 95 after Build 950a on the installation discs as an optional installation configurable and installable by means of the Control Panel, and then a standard component of Windows 98 and subsequent and Windows NT 4.0 Build 1381 and by means of Service Pack 4. The WSH is also a means of automation for Internet Explorer via the installed WSH engines from IE Version 3.0 onwards; at this time VBScript became means of automation for Microsoft Outlook 97. The WSH is also an optional install provided with a VBScript and JScript engine for Windows CE 3.0 and following and some third-party engines including Rexx and other forms of Basic are also available.

<span class="mw-page-title-main">FLTK</span>

Fast Light Toolkit is a cross-platform widget library for graphical user interfaces (GUIs), developed by Bill Spitzak and others. Made to accommodate 3D graphics programming, it has an interface to OpenGL, but it is also suitable for general GUI programming.

<span class="mw-page-title-main">Graphical widget</span> Element of interaction in a graphical user interface

A graphical widget in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through direct manipulation to read or edit information about an application. User interface libraries such as Windows Presentation Foundation, Qt, GTK, and Cocoa, contain a collection of controls and the logic to render these.

<span class="mw-page-title-main">PyQt</span> Python GUI library

PyQt is a Python binding of the cross-platform GUI toolkit Qt, implemented as a Python plug-in. PyQt is free software developed by the British firm Riverbank Computing. It is available under similar terms to Qt versions older than 4.5; this means a variety of licenses including GNU General Public License (GPL) and commercial license, but not the GNU Lesser General Public License (LGPL). PyQt supports Microsoft Windows as well as various flavours of UNIX, including Linux and MacOS.

<span class="mw-page-title-main">Fox toolkit</span>

The FOX toolkit is an open-source, cross-platform widget toolkit, i.e. a library of basic elements for building a graphical user interface (GUI). FOX stands for Free Objects for X.

wxPython Python wrapper for wxWidgets

wxPython is a wrapper for the cross-platform GUI API wxWidgets for the Python programming language. It is one of the alternatives to Tkinter. It is implemented as a Python extension module.

<span class="mw-page-title-main">VTK</span>

The Visualization Toolkit (VTK) is an open-source software system for 3D computer graphics, image processing and scientific visualization.

Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de facto standard GUI. Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python.

<span class="mw-page-title-main">Tkhtml</span>

Tkhtml is a discontinued open-source browser engine written in C using the Tk widget toolkit. It was used primarily by the Html Viewer 3 (Hv3) minimalist web browser.

Clutter is a discontinued GObject-based graphics library for creating hardware-accelerated user interfaces. Clutter is an OpenGL-based 'interactive canvas' library and does not contain any graphical control elements. It relies upon OpenGL (1.4+) or OpenGL ES for rendering,. It also supports media playback using GStreamer and 2D graphics rendering using Cairo.

ReAction GUI is the widget toolkit engine that is used in AmigaOS 3.2-4.1.

<span class="mw-page-title-main">Scripting language</span> Programming language for run-time events

A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.

<span class="mw-page-title-main">PySide</span>

PySide is a Python binding of the cross-platform GUI toolkit Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the alternatives to the standard library package Tkinter. Like Qt, PySide is free software. PySide supports Linux/X11, macOS, and Microsoft Windows.

Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful. Tcl casts everything into the mold of a command, even programming constructs like variable assignment and procedure definition. Tcl supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles.

In computer science and visualization, a canvas is a container that holds various drawing elements. It takes its name from the canvas used in visual arts. It is sometimes called a scene graph because it arranges the logical representation of a user interface or graphical scene. Some implementations also define the spatial representation and allow the user to interact with the elements via a graphical user interface.


  1. "Tcl/Tk Core Development". Tcl Developer Xchange. Retrieved 1 November 2016.
  2. "[TCLCORE] Tcl/Tk 8.6.13 RELEASED".
  3. "Tcl/Tk Licensing Terms". Tcl Developer Xchange. Retrieved 4 November 2016.
  4. Writing a Tk Widget in C, Chapter 46 in Practical Programming in Tcl and Tk, ISBN   0-13-038560-3
  5. "Extensions for Tcl and Tk". Tcler's Wiki. Retrieved 1 November 2016.
  6. "Tcl/Tk 8.0". Tcl Developer Xchange. 18 September 2013. Retrieved 1 July 2014.
  7. "Tile: an improved themeing engine for Tk". SourceForge. Retrieved 4 November 2016.
  8. 1 2 "Tcl/Tk 8.5 Release Announcement". Tcl Developer Xchange. 18 September 2013. Retrieved 1 July 2014.
  9. "Tcl/Tk 8.6 Release Announcement". Tcl Developer Xchange. 20 September 2013. Retrieved 1 July 2014.
  10. Ousterhout, John. "History of Tcl". Tcl Developer Exchange. Retrieved 1 April 2010.
  11. "Tk Backgrounder". TkDocs. Retrieved 4 November 2016.
  12. "John K Ousterhout - Award Winner". ACM Awards. Retrieved 4 November 2016.
  13. "TIP #48: Tk Widget Styling Support". Tcl Developer Xchange. Retrieved 1 November 2016.
  14. "treeview". Tcler's Wiki. Retrieved 1 November 2016.
  15. "TIP #319: Implement Backwards Compatibility for ttk Themed Widgets in tk Widgets". Tcl Developer Xchange. Retrieved 1 November 2016.
  16. "wish manual page - Tk Applications". Tcl Developer Xchange. Retrieved 1 November 2016.
  17. "How to Compile Tcl". Tcl Developer Xchange. Retrieved 1 November 2016.
  18. "ttk::widget manual page - Tk Themed Widget". Tcl Developer Xchange. Retrieved 1 November 2016.
  19. "option manual page - Built-In Commands". Tcl Developer Xchange. Retrieved 1 November 2016.
  20. "Languages with a Tk binding". Tcler's Wiki. Retrieved 1 July 2014.
  21. "TASH". SourceForge. Retrieved 1 July 2014.
  22. "HTk home". Informatik - FB3 - Uni Bremen. Retrieved 4 November 2016.
  23. "Tkx::Tutorial - How to use Tkx". ActiveState Docs. Retrieved 1 November 2016.
  24. Perl/Tk Concepts, Chapter 1 in Mastering Perl/Tk, ISBN   978-1565927162
  25. Tkinter, Chapter 2.4 in Modern Tkinter for Busy Python Developers, ASIN   B0071QDNLO
  26. "Tk Commands, version 8.6.6". Tcl Developer Xchange. Retrieved 1 November 2016.
  27. Widgets', Chapter 17.2 in Tcl and the Tk Toolkit , ISBN   978-0321336330
  28. Geometry Managers', Chapter 17.6 in Tcl and the Tk Toolkit , ISBN   978-0321336330

Further reading