Tk (software)
   HOME

TheInfoList



OR:

Tk is a
cross-platform Within 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 platform, computing platforms. Some ...
widget toolkit A widget toolkit, widget library, GUI toolkit, or UX library is a library (computing), library or a collection of libraries containing a set of graphical control elements (called ''widgets'') used to construct the graphical user interface (GUI) of ...
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 m ...
s for building a
graphical user interface A graphical user interface, or GUI, is a form of user interface that allows user (computing), users to human–computer interaction, interact with electronic devices through Graphics, graphical icon (computing), icons and visual indicators such ...
(GUI) in many programming languages. It is
free and open-source software Free and open-source software (FOSS) is software available under a license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term encompassing free ...
released under a
BSD The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginni ...
-style
software license A software license is a legal instrument governing the use or redistribution of software. Since the 1970s, software copyright has been recognized in the United States. Despite the copyright being recognized, most companies prefer to sell lic ...
. 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 Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
,
macOS macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
,
Unix Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user 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 Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
. 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 or ''The Unicode Standard'' or TUS is a character encoding standard maintained by the Unicode Consortium designed to support the use of text in all of the world's writing systems that can be digitized. Version 16.0 defines 154,998 Char ...
within the
Basic Multilingual Plane In the Unicode standard, a plane is a contiguous 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 hexadecimal ...
, but it has not yet been extended to handle the current extended full
Unicode Unicode or ''The Unicode Standard'' or TUS is a character encoding standard maintained by the Unicode Consortium designed to support the use of text in all of the world's writing systems that can be digitized. Version 16.0 defines 154,998 Char ...
(e.g.,
UTF-16 UTF-16 (16-bit Unicode Transformation Format) is a character encoding that supports all 1,112,064 valid code points of Unicode. The encoding is variable-length as code points are encoded with one or two ''code units''. UTF-16 arose from an earli ...
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 an American computer scientist. He is a professor of computer science at Stanford University. He founded Electric Cloud with John Graham-Cumming. Ousterhout was previously a professor of com ...
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 Fast Light Toolkit (FLTK) is a cross-platform widget (graphical control element) 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 ...
, Qt, and
GTK GTK (formerly GIMP ToolKit and GTK+) is a free software 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 software, free and ...
. Widgets that became commonly used in applications (e.g. trees,
combo box A combo box is a commonly used graphical user interface A graphical user interface, or GUI, is a form of user interface that allows user (computing), users to human–computer interaction, interact with electronic devices through Graphics, gr ...
es, 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. Sociology Several cu ...
(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), Go (through ),
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 pioneered several programming language ...
(called HTk),
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
,
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 (prog ...
(called
Tkinter Tkinter is a binding to the Tk GUI toolkit for Python. 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 Pyth ...
), R (through the standard package: tcltk),
Ruby 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 sapph ...
,
Rexx Rexx (restructured extended executor) is a high-level programming language developed at IBM by Mike Cowlishaw. Both proprietary and open-source software, open source Rexx interpreter (computing), interpreters exist for a wide range of comput ...
, and
Common Lisp Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
. There are several ways to use Tk from
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
: 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 (prog ...
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 In computing, a dialog box (also 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 are classified as " modal" or "modeless", dep ...
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 This article provides a list of widget toolkits (also known as GUI frameworks), used to construct the graphical user interface (GUI) of programs, organized by their relationships with various operating systems. Low-level widget toolkits Integrat ...
*
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 GUI ...
* Expect *
Tkinter Tkinter is a binding to the Tk GUI toolkit for Python. 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 Pyth ...
– 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 a major American publishing#Textbook_publishing, educational publisher. It published print and digital content for the 6–12 and higher-education market. It was an independent company throughout the bulk of the twentieth cen ...
, Upper Saddle River, NJ, USA, , 2003 * J Adrian Zimmer,
Tcl/Tk for Programmers
'',
IEEE Computer Society IEEE Computer Society (commonly known as the Computer Society or CS) is a technical society of the Institute of Electrical and Electronics Engineers (IEEE) dedicated to computing, namely the major areas of hardware, software, standards and people ...
, 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 ...
, Reading, MA, USA, , 1998 * Bert Wheeler,
Tcl/Tk 8.5 Programming Cookbook
',
Packt Publishing Packt is a publishing company founded in 2003 and 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 ...
, 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