Tkinter vs wxPython: your opinions?

Neil Cerutti cerutti at together.net
Thu Jan 25 14:41:19 EST 2001


Dethe Elza posted:
>Purely anecdotal information:
>
>I was building a simple app in wxPython on Windows because I'd
>heard Tkinter was 'too slow.' Things were relatively OK, but
>when I tried to run it on Linux some functions were not yet
>implemented and the program would coredump frequently.
>wxPython/wxWindows is a swiftly moving target, so these problems
>may well be fixed now.  But I ported to Tkinter and it's been
>fast enough for my limited needs, and with Tkinter 3000 I expect
>it to be even faster (haven't had time to test that yet, perhaps
>this weekend).
>
>Using Tkinter also has the advantage that it will work on my
>antique Mac Duo which my 4-year old daughter uses for games.
>This is pretty crucial for me, since what I'm writing is
>basically a game for her.

The current documentation for Tkinter is much better than what is
available for wxPython. 

For comparison purposes, I'm writing my first GUI app, a simple
wrapper for slrn, in Tkinter and wxPython.

Tkinter's 'pack' layout manager is super easy to use, and with
some practice and the excellent documentation, powerful. wxPython
seems to have a couple of layout managers, but how they should be
used is a mystery. I've been forced to place everything pixel by
pixel so far.

wxPython is supposed to be faster, but it isn't for the tiny app
I've written, because it takes nearly 3 times as long to get
started.

Binding widgets to callbacks in Tkinter is much easier for me to
understand than the wxPython EVT_ macros. Tkinter's events seem
much easier to bind, since I don't have to worry about which
widget generates what event -- they all seem to generate everything
I've wanted to bind. In wxPython, I haven't figured out how to
get my app to close if I hit ESC. Nothing I've tried EVT_CHARing
has bothered to actually generate an event.

The objects in wxPython are more full-featured (I guess--for some
definition of full featured), but aren't as easily configurable
as the Tkinter ones. For example, in Tkinter, I've bound
right-clicking to a list box of news servers. A popup menu allows
me to remove that new server from the list, or add another one. I
can catch a EVT_RIGHT_BUTTON in wxPython, but I can't (so far)
find out which list item the pointer was near when the event
occurred. (For that matter, I can't make a popup menu either yet
either, though I *know* it's possible. It says in the
documentation that a Menu can be a popup.)

The widgets and windows look exactly the same, so far.

wxPython has access to more standard interface dialogs, though
Tkinter has a fair number, too. The wxPython GUI code is going to
be quite a bit shorter. It would probably lengthen if I started
using a layout manager.

My advice, although I've got limited experience, is to go with
Tkinter, and read the following great document, by Python Labs'
Fredrik Lundh:

http://www.pythonware.com/library/tkinter/introduction/index.htm
  
John Grayson has made a couple of chapters of _Python and
Tkinter_ available for free. One of those free chapters covers
the layout managers and I found it enlightening:

http://www.manning.com/Grayson/Chapters.html

wxPython's documentation seems to be in the state Tkinter's was
back when all there was was the _Tkinter life preserver_.

Better advice is probably to try them both for some small sample
app, like I have, and make up your own mind. Perhaps wxPython
makes perfect sense if you are a good C++ programmer.

-- 
Neil Cerutti <cerutti at together.net>
"If you're gonna score 125 points in a game, you've only got to
play good enough defense to hold the other team to 124. How
the hell hard is that?" -- Red Auerbach



More information about the Python-list mailing list