Tk (software)

This article is about the widget toolkit. For the top-level domain, see .tk. For other uses, see TK.
Tk

Tk 8.6.6 on Windows 10
Original author(s) John Ousterhout
Developer(s) Tcl Core Team[1]
Initial release 1991 (1991)
Stable release
8.6.6 / 27 June 2016 (2016-06-27)
Repository core.tcl.tk/tk
Development status Active
Written in C
Operating system Cross-platform
Platform Cross-platform
Type Widget toolkit
License BSD-style[2]
Website www.tcl.tk

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 (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, 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 32-bit Unicode.

Tk was designed to be extended, and a wide range of extensions are available that offer new widgets or other capabilities.[3][4]

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).[5] Highlights of version 8.5 include a new theming engine, originally called Tk Tile,[6] but now generally referred to as "themed Tk", as well as improved font rendering.[7] Highlights of version 8.6 include PNG support and angled text.[8]

History

Tk was developed by John Ousterhout as an extension for the Tcl scripting language. It was first publicly released in 1991.[9] 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 it being significantly easier to learn and use than Motif and other dominant X11 toolkits of the time.[10] 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). As sign for the popularity and significance in the 1990s, John Ousterhout was awared the ACM Software System Award in 1997 for Tcl/Tk:[11]

ACM Software System Award Winner: John K Ousterhout

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 emulated Motif, despite the mainstream replacement of Motif by toolkits such as Qt and GTK+.[12] 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.[13]

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.[14] 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]

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 (WIndowing SHell) provides a way to bring up a tclsh shell in a graphical window as well as providing Tk.[16]

Tk has the following characteristics:

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.[20] Bindings exist for additional languages which might not be listed, including Ada (called TASH),[21] Haskell (called HTk),[22] Perl, Python (called Tkinter), Ruby, Rexx, and Common Lisp.

There are several ways to use Tk from Perl: the Tcl::Tk and Tkx Perl modules,[23] both of which use Tcl as a bridge to access Tk, and Perl/Tk,[24] which provides native Perl access to Tk structures. The Python binding uses Tcl as a bridge to Tk.[25]

Features

Tk provides various widgets.[26] 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.[27]

Basic Widgets

  • button
  • canvas
  • checkbutton
  • combobox
  • entry
  • frame
  • label
  • labelframe
  • listbox
  • menu
  • menubutton
  • message
  • notebook
  • panedwindow
  • progressbar
  • radiobutton
  • scale
  • scrollbar
  • separator
  • sizegrip
  • spinbox
  • text
  • tk_optionMenu
  • treeview

Top-level Widgets

Geometry Managers

Basic widgets are arranged in toplevel windows using geometry managers.[28]

See also

References

  1. "Tcl/Tk Core Development". Tcl Developer Xchange. Retrieved 2016-11-01.
  2. "Tcl/Tk Licensing Terms". Tcl Developer Xchange. Retrieved 2016-11-04.
  3. Writing a Tk Widget in C, Chapter 46 in Practical Programming in Tcl and Tk, ISBN 0-13-038560-3
  4. "Extensions for Tcl and Tk". Tcler's Wiki. Retrieved 2016-11-01.
  5. "Tcl/Tk 8.0". Tcl Developer Xchange. 2013-09-18. Retrieved 2014-07-01.
  6. "Tile: an improved themeing engine for Tk". SourceForge. Retrieved 2016-11-04.
  7. "Tcl/Tk 8.5 Release Announcement". Tcl Developer Xchange. 2013-09-18. Retrieved 2014-07-01.
  8. "Tcl/Tk 8.6 Release Announcement". Tcl Developer Xchange. 2013-09-20. Retrieved 2014-07-01.
  9. Ousterhout, John. "History of Tcl". Tcl Developer Exchange. Retrieved 1 April 2010.
  10. "Tk Backgrounder". TkDocs. Retrieved 2016-11-04.
  11. "John K Ousterhout - Award Winner". ACM Awards. Retrieved 2016-11-04.
  12. "TIP #48: Tk Widget Styling Support". Tcl Developer Xchange. Retrieved 2016-11-01.
  13. "treeview". Tcler's Wiki. Retrieved 2016-11-01.
  14. "Tcl/Tk 8.5 Release Announcement". Tcl Developer Xchange. 2013-09-18. Retrieved 2014-07-01.
  15. "TIP #319: Implement Backwards Compatibility for ttk Themed Widgets in tk Widgets". Tcl Developer Xchange. Retrieved 2016-11-01.
  16. "wish manual page - Tk Applications". Tcl Developer Xchange. Retrieved 2016-11-01.
  17. "How to Compile Tcl". Tcl Developer Xchange. Retrieved 2016-11-01.
  18. "ttk::widget manual page - Tk Themed Widget". Tcl Developer Xchange. Retrieved 2016-11-01.
  19. "option manual page - Built-In Commands". Tcl Developer Xchange. Retrieved 2016-11-01.
  20. "Languages with a Tk binding". Tcler's Wiki. Retrieved 2014-07-01.
  21. "TASH". SourceForge. Retrieved 2014-07-01.
  22. "HTk home". Informatik - FB3 - Uni Bremen. Retrieved 2016-11-04.
  23. "Tkx::Tutorial - How to use Tkx". ActiveState Docs. Retrieved 2016-11-01.
  24. Perl/Tk Concepts, Chapter 1 in Mastering Perl/Tk, ISBN 978-1565927162
  25. Tkinter, Chapter 2.4 in Modern Tkinter for Busy Python Developers, ASIN B0071QDNLO
  26. "Tk Commands, version 8.6.6". Tcl Developer Xchange. Retrieved 2016-11-01.
  27. Widgets', Chapter 17.2 in Tcl and the Tk Toolkit , ISBN 978-0321336330
  28. Geometry Managers', Chapter 17.6 in Tcl and the Tk Toolkit , ISBN 978-0321336330

Further reading

Wikibooks has a book on the topic of: Tcl Programming/Tk
This article is issued from Wikipedia - version of the 11/19/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.