HOME

TheInfoList



OR:

Tk is a
free and open-source Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source ...
,
cross-platform In computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several computing platforms. Some cross-platform software ...
widget toolkit A widget toolkit, widget library, GUI toolkit, or UX library is a library or a collection of libraries containing a set of graphical control elements (called ''widgets'') used to construct the graphical user interface (GUI) of programs. Most wid ...
that provides a library of basic elements of
GUI widget A graphical widget (also graphical control element or control) 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 di ...
s for building a
graphical user interface The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows User (computing), users to Human–computer interaction, interact with electronic devices through graphical icon (comp ...
(GUI) 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 Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
,
Mac OS Two major famlies of Mac operating systems were developed by Apple Inc. In 1984, Apple debuted the operating system that is now known as the "Classic" Mac OS with its release of the original Macintosh System Software. The system, rebranded " ...
,
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
, and Microsoft Windows. Like Tcl, Tk supports
Unicode Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, ...
within the
Basic Multilingual Plane In the Unicode standard, a plane is a continuous group of 65,536 (216) code points. There are 17 planes, identified by the numbers 0 to 16, which corresponds with the possible values 00–1016 of the first two positions in six position hexadecim ...
, but it has not yet been extended to handle the current extended full
Unicode Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, ...
(e.g.,
UTF-16 UTF-16 (16-bit Unicode Transformation Format) is a character encoding capable of encoding all 1,112,064 valid code points of Unicode (in fact this number of code points is dictated by the design of UTF-16). The encoding is variable-length, as cod ...
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. 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). Highlights of version 8.5 include a new theming engine, originally called Tk Tile, but it is 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 Motif may refer to: General concepts * Motif (chess composition), an element of a move in the consideration of its purpose * Motif (folkloristics), a recurring element that creates recognizable patterns in folklore and folk-art traditions * Moti ...
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 (released 1997). To mark the popularity and significance of Tk in the 1990s, Ousterhout was given the
ACM Software System Award The ACM Software System Award is an annual award that honors people or an organization "for developing a software system that has had a lasting influence, reflected in contributions to concepts, in commercial acceptance, or both". It is awarded by ...
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 Motif may refer to: General concepts * Motif (chess composition), an element of a move in the consideration of its purpose * Motif (folkloristics), a recurring element that creates recognizable patterns in folklore and folk-art traditions * Moti ...
, despite the mainstream replacement of Motif by toolkits such as FLTK, Qt and GTK. 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. 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 (tclsh), Tk may be invoked using the command package require Tk. The program
wish A wish is a hope or desire for something. In fiction, wishes can be used as plot devices. In folklore, opportunities for "making a wish" or for wishes to "come true" or "be granted" are themes that are sometimes used. In fiction In ficti ...
(WIndowing SHell) provides a way to run a tclsh shell in a graphical window as well as providing Tk. Tk has the following characteristics: * Platform-independent: Like Tcl, Tk is interpreted. It has been ported to multiple platforms and can easily run on all of them without modification. * Customizable: Almost all the features of a widget in Tk are customizable through options during the creation of the widget or later on through the configure command. * Configurable: Many of the options can be stored in an option database, making it very easy to parameterize the look of an application (such as the color scheme). This also means that storing the application-specific options is only a matter of saving the option add commands and executing them on loading the application.


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. Bindings exist for additional languages which might not be listed, including Ada (called TASH), Haskell (called HTk),
Perl Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
, Python (called Tkinter), R (through the standard package: tcltk),
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapp ...
,
Rexx Rexx (Restructured Extended Executor) is a programming language that can be interpreted or compiled. It was developed at IBM by Mike Cowlishaw. It is a structured, high-level programming language designed for ease of learning and reading. ...
, and
Common Lisp Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ''ANSI INCITS 226-1994 (S20018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived fr ...
. There are several ways to use Tk from
Perl Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
: 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

* tk_chooseColor – pops up a
dialog box The dialog box (also called dialogue box (non-U.S. English), message box or simply dialog) is a graphical control element in the form of a small window that communicates information to the user and prompts them for a response. Dialog boxes ar ...
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.


Geometry managers

Basic widgets are arranged in toplevel windows using geometry managers:''Geometry Managers', Chapter 17.6 in ''Tcl and the Tk Toolkit '', * place – positions widgets at absolute locations * grid – arranges widgets in a grid * pack – packs widgets into a cavity


See also

* List of widget toolkits * wish (Windowing Shell) * Expect * Tkinter – a Tk binding for Python * Itk * :Software that uses Tk (software)


References


Further reading

* * * Brent B. Welch,
Practical Programming in Tcl and Tk
',
Prentice Hall Prentice Hall was an American major educational publisher owned by Savvas Learning Company. Prentice Hall publishes print and digital content for the 6–12 and higher-education market, and distributes its technical titles through the Safari B ...
, Upper Saddle River, NJ, USA, , 2003 * J Adrian Zimmer,
Tcl/Tk for Programmers
',
IEEE Computer Society The Institute of Electrical and Electronics Engineers (IEEE) is a 501(c)(3) professional association for electronic engineering and electrical engineering (and associated disciplines) with its corporate office in New York City and its operati ...
, distributed by John Wiley and Sons, , 1998 * Mark Harrison and Michael McLennan,
Effective Tcl/Tk Programming
',
Addison-Wesley Addison-Wesley is an American publisher of textbooks and computer literature. It is an imprint of Pearson PLC, a global publishing and education company. In addition to publishing books, Addison-Wesley also distributes its technical titles throug ...
, Reading, MA, USA, , 1998 * Bert Wheeler,
Tcl/Tk 8.5 Programming Cookbook
', Packt Publishing, Birmingham, England, UK, , 2011 * Clif Flynt ''Tcl/Tk, Third Edition: A Developer’s Guide'', , 2012


External links

*
Tcler's Wiki



Tk docs
modern Tk tutorial for Tcl, Ruby, Perl and Python *
Languages with a Tk binding
{{DEFAULTSORT:Tk (Framework) Application programming interfaces Free computer libraries Tcl programming language family Widget toolkits