GUIs: wxPython vs. Tkinter (and others)

Fredrik Lundh fredrik at pythonware.com
Sat Dec 11 04:38:01 EST 2004


Mike Meyer wrote:

> I don't know about wxPython, but PyQt includes it's own threading
> facility, plus hooks to talk to databases.

That would of course be a great argument if Python didn't already have
a threading facility, and a standard API for talking to databases with
implementations for all major players.

> 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)

>>     o Is the general programming methodology pretty much the same between
>> the two (e.g., the general program structure - using callbacks & Frames,
>> etc. is the same, it's just a question of calling different widgets with
>> their own arguments)?
>
> Not for Qt. It has the notion of SLOTs and SIGNALs. You connect a
> signal from an object to a slot or signal on another (or the same)
> object. You can, for example, connect a signal from a slider widget to
> a slot on a digital display widget, thus causing the display to change
> as you move the slider.
>
> 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).

If you want bind an event source (signal) to a slot (method) in one line,
use a lambda.  If you need to add more behaviour (you usually do), use
a function.

> 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.

(or you're borrowing it from Trolltech's marketing material; I notice that
the phrase "higher level of abstraction" is very popular amont Qt fans, but
Trolltech themselves only seem to use it when they talk about lower-level
libraries like X/Xt/Motif and the native Win32 API)

> 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.

(for more advanced drawing, I'd recommend OpenGL, which is available
for them all)

</F> 






More information about the Python-list mailing list