pygtk2 vs. pyqt. pros and cons

Geoff Gerrietts geoff at gerrietts.net
Sat Mar 1 03:44:47 CET 2003


Quoting gabor (gabor at z10n.net):
> so if you are familiar with both of them,
> please tell me about your experiences, and
> tell me which one do you recommend.

I just spent a little time developing a pyqt version of a pygtk tool I
had previously written. I'm not tremendously experienced, but I've
written code in both GUIs: I've written a lot more pygtk code, but
it's all based on the Gtk 1 toolkit, so times have probably changed
around me.

Under pygtk and gtk, I developed "both ways": doing things by hand,
and doing things with Glade + libglade. Of the two, the former was
cleaner and the latter was more convenient. Neither was preferable to
using Qt Designer and pyuic to generate template code. So, in the
"ease of rapid development" camp, I would hafta say qt kicks the snot
out of gtk.

Under qt, the generated code is built onto a single class, which you
are expected to subclass and fill out with handlers. The resulting
architecture has your "widgets" in a generated module, then your
handlers in a second module, and the two linked by inheritance. Under
gtk, I never developed this way, though I could have: I had handlers
in one class hierarchy, and widgets in another, and I used some
unfortunate black magic to blend the two.

I personally prefer using composition to inheritance for this (better
reusability), but neither architecture did a terribly good job of
permitting me this option. Gtk has the dubious distinction of making
it possible.

I had some real problems coming up with a convenient way to make a
combo box or selection widget work for me under Gtk. I saw a couple
posts around indicating that the API for some of these things changed
in Gtk 2, but the change didn't seem dramatic enough for my tastes. I
found it much easier to get these controls working "as expected" under
Qt -- but if I wanted finer-grained control, I might find the Qt API
to lack granularity. I don't think so, but it's possible. The Gtk
version of the file selection dialog had some bad juju lingering
around it, also; I hear a rumor that they're going to fix it but I
haven't confirmed that for myself.

Both toolkits are fully-featured, though, with a great variety of
controls and a lot of available tools. My experience to date has been
that Qt is really the better choice, except maybe in regards to
licensing, and possibly with respect to architecture. Others may have
differing opinions, but I think the bottom line is that you won't go
wrong with either choice.

Thanks,
--G.

-- 
Geoff Gerrietts <geoff at gerrietts dot net>      http://www.gerrietts.net/
   "If I were two-faced, would I be wearing this one?" --Abraham Lincoln





More information about the Python-list mailing list