Wednesday, September 23, 2009

Quest for a GUI

This pythonista loves to do GUI work, but what package to use? What features are we looking for and most importantly for me, how easy is it to install and configure on a target machine?

So, I've been using Tcl/TK with Python and find it suits most of my needs for a simple interface but more and more I'm getting to write applications that are more complex than a few simple modal dialog boxes popping up all over the place.

Tix, which is an extension of Tcl/TK for python gives us more variety in terms of widgets, the widgets I'm most interested right now is the hierarchical list and the tree widget.

I took out Tix for a test drive and right out of the box, there are problems but not so insurmountable that they can't be solved. To begin...

I'm developing with python 2.5 (still supports all the 3rd party tools I have come to know and love) and getting Tix 3.4 to work gave me problems on Windows.

I ran the DemoSHList demo and right away it gave me problems.

The line:


boldfont=hlist.tk.call('tix','option','get','bold_font')


was giving me this annoying error:


_tkinter.TclError: can't read "tixOption(bold_font)": no such element in array


what to do, what to do: It seems as if some Tix stuff is broken in windows (The linux side is another matter entirely!!) and to make a long story short, the fonts and colors are not setup properly for the windows environment.

The fix is relatively simple affair to do, just remind Tix exactly what kind of operating system its running. Just place this line before you call what you think is a system-defined constant.


hlist.tk.call('tix', 'configure', '-fontset', 'WmDefault')


This will set it to the its Window defaults. I would imaging this will be fixed in the next installment but in the meantime, adding the above line won't hurt and will just become redundant in the future.

Running the tree sample, which merely enumerates the contents of my disk worked right out of the box with no changes.

I'll be updating all my Tk code to take advantage of Tix.

I'll keep you posted if I find any other issues in the windows side.

The linux side will have to wait for a bit since my entire customer base is windows based and the only person who uses the tool in linux is myself so I can afford to wait a bit.

No comments:

Post a Comment