Tuesday, May 21, 2013

Tix, ttk and Tkinter

Tkinter is the graphical package based on Tk that ships standard with most Python builds. But Python 2.7 also has ttk and Tix, which leads to some confusion. Right away this is partially cleared up in the reference for ttk, which describes it as an extension to Tkinter that provides missing widgets. But along comes Tix, which says more or less the same thing. Even more confusing, is that we are encouraged to import ttk as follows:

    >>> from Tkinter import *
    >>> from ttk import *

so that those widgets replaced by ttk will be imported over the older ones in Tkinter.

These include:

WidgetTkinterttk
ButtonXX
CanvasX
CheckbuttonXX
ComboboxX
EntryXX
FrameXX
LabelXX
LabelFrameXX
ListboxX
MenuX
MenubuttonXX
MessageX
NotebookX
OptionMenuX
PanedWindowXX
ProgressbarX
RadiobuttonXX
ScaleXX
ScrollbarXX
SeparatorX
SizegripX
SpinboxXTk8.5.9
TextX
TreeviewX
ToplevelX

I'm not going to include Tix because there are over 40 widgets that are added, but there are two important differences between Tix and ttk.
  • Tix hasn't seen development since 2008 whereas ttk was last upgraded in 2012
  • Tix isn't part of Tk/Tcl - it is a 3rd party add-on.
In general ttk looks newer than Tix. Here are some screen shots of a Tix Meter widget and ttk Progressbar widget.
Tix Meter widget
Tix Meter Widget

ttk Progressbar widget
ttk Progressbar widget

So I think I'm going to stick with ttk imported on top of Tkinter as suggested by Python, and I'll only supplement these widgets with Tix if I absolutely must, since the ttk widgets really do seem better.

Fork me on GitHub