Tk (software)


Tk is a free and open-source, cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface in many programming languages.
Tk provides a number of 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, Mac OS, 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.
Tk was designed to be extended, and a wide range of extensions are available that offer new widgets or other capabilities.
Since Tcl/Tk 8, it offers "native look and feel". Highlights of version 8.5 include a new theming engine, originally called Tk Tile, but now generally referred to as "themed Tk", as well as improved font rendering. Highlights of version 8.6 include PNG support and angled text.

History

Tk was developed by John Ousterhout as an extension for the Tcl scripting language. It was first publicly released in 1991. 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. 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. To mark the popularity and significance of Tk in the 1990s, Ousterhout was given the ACM Software System Award in 1997 for Tcl/Tk:
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. Widgets that became commonly used in applications were not available in the Tk core, but only via multiple, often competing add-ons.
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.
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.

Architecture

Tk is a platform-independent GUI framework developed for Tcl. From a Tcl shell, Tk may be invoked using the command package require Tk. The program wish provides a way to bring up a tclsh shell in a graphical window as well as providing Tk.
Tk has the following characteristics:
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. Bindings exist for additional languages which might not be listed, including Ada, Haskell, Perl, Python, Ruby, Rexx, and Common Lisp.
There are several ways to use Tk from Perl: the Tcl::Tk and Tkx Perl modules, both of which use Tcl as a bridge to access Tk, and Perl/Tk, which provides native Perl access to Tk structures. The Python binding uses Tcl as a bridge to Tk.

Features

Tk provides various widgets. 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.

Basic widgets

Top-level widgets

Basic widgets are arranged in toplevel windows using geometry managers: