Home Contact

TkDocs

Information you need to build high-quality Tk user interfaces.

close

Modern Tkinter ebook If you've found the material on this site useful, please consider purchasing this e-book (only $10), which is based on the Python material in the tutorial. Doing so helps me maintain and update this site. Thank you very much!


 
 
@markroseman
mark@markroseman.com

 

Kindle Buy now for your Kindle
Kindle apps are also available for most smartphones, tablets, and desktops. Payment and download handled by Amazon's Kindle Store.

 

PDF Buy the DRM-free PDF
Downloads handled by SendOwl.com. Payment handled via PayPal
(click "Don't have a PayPal account" to use a credit card).

What is Tk? Why do I care? Where did it come from? Who owns it? Is it actively developed? Isn't it something those old guys used to use? Do I need to know Tcl to use it?

Tk Backgrounder

Tk is a user interface toolkit that makes it easy to build desktop graphical user interfaces. Tk is cross-platform, meaning the same code can be made to run the same on Windows, Mac OS X, or X11 under a huge range of Unix systems (e.g. Linux). Compared with most user interface toolkits, Tk is also quite high level, meaning that it takes care of a lot of details for you. Tk is also unique in that it was designed from the start to be paired with a high level dynamic programming language (like Tcl, Python, Ruby, Perl) as opposed to lower-level languages like C or C++. In fact, you'll find a Tk binding for most dynamic languages available today. It also is BSD-licensed, making it attractive for both open source and commercial developers.

Taken together, these factors make Tk an attractive option for people trying to develop a GUI on Windows, Mac or Unix, especially if they want it to run on all three. And because Tk is used from dynamic programming languages, it's an accessible tool not only for hardcore developers, but also many people without a computer science or engineering background.

Because it's been around for a very long time, and changed a lot over the years, there's a lot of horridly outdated and therefore incorrect information out there. This makes extracting the truth pretty overwhelming if you just want to figure out if and how to use Tk today. While that's mostly what this site will help with, a brief history of where it came from, why and how it caught on, and how things have evolved until today will help put a whole lot of things in context.

The Early Years

Tk was created around 1988 by John Ousterhout, at that time a computer science professor at UC Berkeley. It was developed as a way to easily build GUI's from his Tcl scripting language. Tcl was Unix-only at first, and so Tk ran under X11. The first open source release was around 1991, with fairly rapid adoption starting about a year later. You can find John's recollections of the early years at the main Tcl/Tk developer site, www.tcl.tk.

Tk caught on because lots of people at universities were using Unix/X11 in the early 1990s, and the mainstream X11 libraries like Xt, Xaw and Motif were just horridly painful to use, where a "hello world" application would take literally a couple hundred lines of C or C++. Then Tk comes along, where a good looking "hello world" is a one-liner, and the toolkit took care of all the housekeeping like redrawing, clipping, hit detection, event dispatch and more. It was a no-brainer.

Developers and users of languages other than Tcl paid attention too, and many language bindings to Tk were developed. Python's Tkinter appeared around mid-1994, with Perl's PerlTk soon following.

The Middle Years

In 1994, John moved to Sun Labs, where he assembled a team to help move Tcl/Tk forward even more. The bulk of the team shifted to a startup called Scriptics (later Ajuba), and continued to evolve Tcl/Tk until the company was acquired in 2000, mostly for the non-Tcl/Tk assets the company had developed.

For Tk, those years produced a major step forward, the development of the Windows and Mac versions. This meant that the same script to produce a GUI would run unmodified on Unix, Windows or Mac.

Stewardship of Tk (and Tcl) moved to a more community-centered model in mid-2000, with a Tcl/Tk core team at the center, but with much wider participation.

Tk continued to evolve, but not at a hugely dramatic pace; the incremental enhancements and adding support for new versions of Windows and then Mac OS X precluded much in the way of major leaps forward, and there was almost no core work aimed at following the dueling Gnome/KDE user inteface standards emerging on Linux. Though Tk has always been highly customizable, unless you knew what you were doing and put in the effort, it started looking more and more dated.

Tk Today

Tk 8.5.0 was released in December 20, 2007, and presented as major a step forward as the Windows and Mac versions in 8.0, over ten years earlier. The core distribution included "new" widgets for such now-common components like trees, comboboxes, tabbed notebooks and more, that had only been available before as add-ons (with far too many to choose from).

Most importantly, Tk 8.5 added a new "themed" widget set, which complements but does not replace the "classic" widget set. The classic widgets provide full backwards-compatibility, retaining their almost infinite flexibility, but often dated appearance. The new themed widgets look much better on their respective platforms out of the box, and developers should generally use them for nearly all mainstream user interface needs. The new widgets also support changing their look and feel via themes, making "skinnable" user interfaces easy for applications and platforms where they are appropriate.

Tk 8.5 is a milestone release. Though there are still some rough edges, and the full transition from "classic" to "themed" widgets will take some time (and some developer effort), this represents the first time in recent memory that everything needed to build good looking Tk applications is available in the core, without huge amounts of tweaking and add-ons.