GUIs: wxPython vs. Tkinter (and others)
mwm at mired.org
Sun Dec 12 05:49:47 CET 2004
"Fredrik Lundh" <fredrik at pythonware.com> writes:
> Mike Meyer wrote:
>> It also has a widget for creating Windows "wizards" for walking
>> through a set of options.
> Besides the fact that wizards isn't really that great (read Cooper), if your
> toolkit doesn't let you create a dialogue with a couple of buttons and a
> swappable frame, it's not a very good toolkit. (that's very easy, in both
> Tkinter and wxPython. You can probably find ready-made modules on
> the net if you look around a little)
While I'm not a big fan of wizards, for some applications they are
just the ticket, as you're walking down a tree of options. Presenting
the user the options at each node is exactly the way to go. Sure, it
may be easy to roll your own in TkInter, but in PyQt you don't have to.
>> At the python level, slots are just callable objects. At the
>> C++ level, slots are magic methods of objects. Signals are usually
>> associated with GUI events, but Python can emit them for whatever
>> reason it wants. It's possible to connect C++ signals to C++
>> slots/signals in Python, meaning that Python won't be involved when
>> that signal is emitted.
> That's would of course be a great argument if you didn't have Python.
> (even if Python's slower than C++, it's a lot faster than a user).
It's still nice to be able to let the C++ code handle it all. After
all, having the compiled layer do things for you is what makes for
fast python code.
>> PyQt provides a higher level of abstraction.
> Whan what? C++ plus a low level UI API, sure. But Tkinter+Python?
> wxPython+Python? You gotta be kidding.
No, I'm not kidding. I'm stating my general impression after having
done programming with both TkInter and PyQt. Note, that's *Py*Qt, not
>> I've never tried doing animation in TkInter. Qt provides timer devices
>> that you can use to drive animations. I suspect that doing the same in
>> TkInter would be noticably more difficult.
> Eh? You don't know how to do a loop in Python? Or register a callback?
> wxPython contains both timers and a low-level graphics API; for Tkinter,
> you the "after" facility and the Canvas; if you need lower-level drawing
> with tighter Python intergration, use the WCK.
Sure, you can roll a loop together with a sleep and do animation. You
can throw in threading and queues so you can keep the GUI active while
you're doing it. With Qt, you tie the timer's signal to the
object-moving function, and you're done. Since you have to use the
threaded version to get the same functionality, I'd say noticably more
difficult isn't an overstatement.
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list