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 r ...
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 widg ...
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 direct ...
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 users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
(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 ...
,
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 "M ...
,
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, and ot ...
, and
Microsoft Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
. Like
Tcl
TCL or Tcl or TCLs may refer to:
Business
* TCL Technology, a Chinese consumer electronics and appliance company
**TCL Electronics, a subsidiary of TCL Technology
* Texas Collegiate League, a collegiate baseball league
* Trade Centre Limited ...
, Tk supports
Unicode
Unicode, formally The Unicode Standard,The formal version reference is is an information technology Technical standard, standard for the consistent character encoding, encoding, representation, and handling of Character (computing), text expre ...
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 hexadecima ...
, 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 Technical standard, standard for the consistent character encoding, encoding, representation, and handling of Character (computing), text expre ...
(e.g.,
UTF-16
UTF-16 (16-bit computing, 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 variab ...
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
John Kenneth Ousterhout (, born October 15, 1954) is a professor of computer science at Stanford University. He founded Electric Cloud with John Graham-Cumming. Ousterhout was a professor of computer science at University of California, Berkeley ...
as an extension for the
Tcl
TCL or Tcl or TCLs may refer to:
Business
* TCL Technology, a Chinese consumer electronics and appliance company
**TCL Electronics, a subsidiary of TCL Technology
* Texas Collegiate League, a collegiate baseball league
* Trade Centre Limited ...
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 (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 b ...
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
GTK (formerly GIMP ToolKit and GTK+) is a free and open-source cross-platform widget toolkit for creating graphical user interfaces (GUIs). It is licensed under the terms of the GNU Lesser General Public License, allowing both free and propriet ...
. 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
A framework is a generic term commonly referring to an essential supporting structure which other things are built on top of.
Framework may refer to:
Computing
* Application framework, used to implement the structure of an application for an op ...
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 fictio ...
(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
Ada may refer to:
Places
Africa
* Ada Foah, a town in Ghana
* Ada (Ghana parliament constituency)
* Ada, Osun, a town in Nigeria
Asia
* Ada, Urmia, a village in West Azerbaijan Province, Iran
* Ada, Karaman, a village in Karaman Province, ...
(called TASH),
Haskell
Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
(called HTk),
Perl
Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
,
Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (pro ...
(called
Tkinter
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.
T ...
),
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 sa ...
,
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 fro ...
.
There are several ways to use Tk from
Perl
Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
: 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
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (pro ...
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
A ''list'' is any set of items in a row. List or lists may also refer to:
People
* List (surname)
Organizations
* List College, an undergraduate division of the Jewish Theological Seminary of America
* SC Germania List, German rugby union ...
*
wish (Windowing Shell)
wish (Windowing Shell) is a Tcl interpreter extended with Tk commands, available for Unix-like operating systems supporting the X Window System, as well as macOS, Microsoft Windows, and Android. It provides developers the ability to create GU ...
*
Expect
Expect is an extension to the Tcl scripting language written by Don Libes. The program automates interactions with programs that expose a text terminal interface. Expect, originally written in 1990 for the Unix platform, has since become avail ...
*
Tkinter
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.
T ...
– a Tk binding for Python
*
Itk
Itk is a framework for building mega-widgets using the Incr Tcl
incr Tcl (commonly stylised as '' ncr Tcl/nowiki>'', and often abbreviated to ''itcl'') is a set of object-oriented extensions for the Tcl programming language. It is widely us ...
*
: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 through ...
, Reading, MA, USA, , 1998
* Bert Wheeler,
Tcl/Tk 8.5 Programming Cookbook',
Packt Publishing
Packt is a publishing company founded in 2003 headquartered in Birmingham, UK,with offices in Mumbai, India.
Packt primarily publishes print and electronic books and videos relating to information technology, including programming, web desig ...
, Birmingham, England, UK, , 2011
* Clif Flynt ''Tcl/Tk, Third Edition: A Developer’s Guide'', , 2012
External links
*
Tcler's WikiTk 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