| Tk | |
|---|---|
Tcl logo | |
Tk 8.6.6 on Windows 10 | |
| Original author | John Ousterhout |
| Developer | Tcl Core Team[1] |
| Initial release | 1991; 35 years ago (1991) |
| Stable release | 9.0.2[2] |
| Written in | C |
| Operating system | Cross-platform |
| Platform | Cross-platform |
| Type | Widget toolkit |
| License | BSD-style[3] |
| Website | tcl.tk |
| Repository | |
Tk is across-platformwidget toolkit that provides a library of basic elements ofGUI widgets for building agraphical user interface (GUI) in many programming languages. It isfree and open-source software released under aBSD-stylesoftware 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 ofLinux,macOS,Unix, andMicrosoft Windows. LikeTcl, Tk 8.6 supportsUnicode within theBasic Multilingual Plane, while Tk 9 supports the fullUnicode range.
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 includePNG support and angled text.[9]
Tk was developed byJohn Ousterhout as an extension for theTcl scripting language. It was first publicly released in 1991.[10] Tkversioning 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 thanMotif 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 theACM Software System Award in 1997 for Tcl/Tk:[12]
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 emulatedMotif, despite the mainstream replacement of Motif by toolkits such asFLTK,Qt, andGTK.[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 GUIframework developed for Tcl. From a Tcl shell (tclsh), Tk may be invoked using the commandpackage require Tk. The programwish (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:
A library written in one programming language may be used in another language ifbindings 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, includingAda (called TASH),[21]Go (through[22]),Haskell (called HTk),[23]Perl,Python (calledTkinter),R (through the standard package: tcltk),Ruby,Rexx, andCommon Lisp.
There are several ways to use Tk fromPerl: the Tcl::Tk and Tkx Perl modules,[24] both of which use Tcl as a bridge to access Tk, and Perl/Tk,[25] which provides native Perl access to Tk structures. ThePython binding uses Tcl as a bridge to Tk.[26]
Tk provides various widgets.[27] Basic widgets are embedded intotoplevel widgets, which in turn are usually hosted by the operating system in floating windows that can be moved around on the screen.[28]
buttoncanvascheckbuttoncomboboxentryframelabellabelframelistboxmenumenubuttonmessagenotebookpanedwindowprogressbarradiobuttonscalescrollbarseparatorsizegripspinboxtexttk_optionMenutreeviewtk_chooseColor – pops up adialog box for the user to select a color.tk_chooseDirectory – pops up a dialog box for the user to select a directory.tk_dialog – creates a modal dialog and waits for a response.tk_getOpenFile – pops up a dialog box for the user to select a file to open.tk_getSaveFile – pops up a dialog box for the user to select a file to save.tk_messageBox – pops up a message window and waits for a user response.tk_popup – posts a popup menu.toplevel – creates and manipulates toplevel widgets.Basic widgets are arranged intoplevel windows using geometry managers:[29]
place – positions widgets at absolute locationsgrid – arranges widgets in a gridpack – packs widgets into a cavity