PyTix - Tix from Python


PyTix is an interface from Python to Tix. PyTix is composed of a single python source file (Tix.py). Small changes are required to the Tk interface from Python i.e., in Tkinter.py and _tkinter.c.

Tix widgets have been represented as classes in Python. Each widget has components which are stored in member variables. For example, a Tix LabelEntry widget is composed of a Label and an Entry widget. These can be referred to as le.label and le.entry (where le is a LabelEntry instance). For example,

	import Tix
	f = Tix.Toplevel()	# Tix imports Tkinter so Tk classes
				# may be used directly
	w = Tix.LabelEntry(f, label='Xyz:')	# Tix compound widget
	w.label['width'] = 10
	w.entry['bg'] = 'cyan'
	w.text.insert(Tix.END, 'Hello, world')

The sub-widget members are created automatically either when the class is instantiated as in LabelEntry or when sub-widgets are added dynamically (as in the case of ButtonBox.

The interface is complete as far as I can tell. Some of the Tix demos have been ported to Python and are included in the distribution.

You can download the latest version of the package here (gzipped tar file). This is version 1.12 which works with Python 1.4, Tcl 7.6, Tk 4.2 and Tix 4.0.5.

What is Python ?

Python (named after Monty Python and not the reptile) is an object-oriented interpreted language invented by Guido van Rossum. It is ideally suited for quick development and prototyping. However, large programs can (and have) been written in Python. For example, Grail is a world wide web browser written entirely in Python. Though Python programs tend to run slower than their C equivalents, the speed of development, reliability (no dangling pointers !) and maintainability (Python is very easy to read) makes for a good argument for writing Python programs. On the other hand, since Python reclaims memory using reference counted objects, it can leak memory when circular references are created ...

More information about Python and how to get it is at the official Python web site


What is Tix ?

Tix is a fancy extension to the Tk toolkit with 'mega-widgets' composed of basic widgets. For example, Tix implements widgets such as ComboBox and FileSelectionBox. The Tix Home Page contains source and documentation for Tix. Tix runs on top of Tcl/Tk which can be found at ftp://ftp.smli.com/pub/tcl .

Although Tix4.1 is in beta, I haven't interfaced PyTix to it yet. This is because for a long time Tix4.1 was commercial software. Only recently has it reverted to being free software so I'd like to see if the release version is free as well before doing anything with it.


Future Plans

I have written most of a Tix replacement called TkXtra (partly prompted by Tix going commercial). This is written entirely in Python (using vanilla Tk) and has a few goodies other than merely more complex widgets (like date entry fields). A few of the more difficult widgets like HList and support for Compound Images is lacking, but it is quite usable in its present form. It is also surprisingly fast considering there is no C code in it. If anyone wants to play with it before it is released, please contact me directly at sshenoy@gol.com.
Sudhir's home