[FAQ] "Best" GUI toolkit for python

Michael Torrie torriem at gmail.com
Tue Oct 18 14:49:35 EDT 2016


On 10/18/2016 10:01 AM, pozz wrote:
> What are the differences between PySides and PyQt... apart the licence?
> Is PySides usable as PyQt?

PySide aims to be pretty close to PyQt. Both of them wrap the C++ api,
so class names and method calls should be identical.  There are some
differences though. PyQt provides a number of python wrappers around
some functionality, (prefixed with pyqt such as pyqtSignal, pyqtSlot,
etc), whereas in PySide would call them just Signal or Slot.  And due to
how PySide generates the bindings, there are occasional bugs that aren't
present in PyQt but can be worked around.  For example,
https://bugreports.qt.io/browse/PYSIDE-79.

PyQt is more mature than PySide, and already supports Qt5, whereas
PySide's support for Qt5 is still in beta as far as I know.  For my
purposes, PySide is as usable as PyQt.  In my latest project I've tried
to keep my code compatible with both PyQt4 and PySide (mainly a matter
of changing some imports).  That said, there's little reason to use
PySide over PyQt if the license for PyQt meets your needs.

> So you have some experience on GTK and QT.  Could you spend some time to 
> describe a few differences? What do you like with Gtk and what you 
> don't? And for Qt?

I do have some experience in both, and in Python.  Lately I've been
using Qt (PySide) since I need to have my project work on Windows and
maybe Mac.  GTK's support for both of those platforms is not so great in
my opinion.

As for differences, well I find that the Python wrappers around Qt are
quite thin and a lot of C++-ims leak up into your Python code. For
example, there are various structures used to wrap up values for passing
things around including QVariant, QPoint, QRect, etc.  In Python there's
less of a need for such wrappers but you have to use them in Qt.  In
some cases the wrapper will convert to a standard Python type like a
list or python string.  But in general you'll find PyQt code feels and
looks a lot like C++ code but in Python, except that MOC stuff is
replaced with decorators (yay!).  I also really find PySide and PyQt's
use of camelCase to be rather ugly (but that's the way Qt is).

Even now I kind of like GTK better than Qt. Not totally sure why. Just
feels a bit better to me.  And the Python bindings for it seem more
pythonic. And it helps that GTK natively uses PEP8-style names for
methods, so the wrappers look more pythonic to me.  As mentioned, GTK
support for Windows and Mac lags behind Linux/X11 or Linux/Wayland and
GTK apps don't feel quite as native there as Qt apps do.  That said, on
Linux I always prefer the look of Gtk apps to Qt apps.

> When you worked with Gtk, have you used Glade as GUI Builder? Could you 
> compare Glade and QT Designer?

Glade is very similar to Qt Designer.  They both do the job and do it in
similar ways.  Designer is probably more polished and mature.  the
"glade-3" command invokes glade for GTK 2.x, and just "glade" invokes
glade for GTK 3. They are separate programs and packages and that can be
very confusing especially when glade-3 is something like version 3.8 and
glade is something like 3.20 (tracks GTK3's version).

And I recommend using the GtkBuilder class to load the Glade xml files
into your app rather than use a code generator.

Your best bet is to create a simple dialog box in both toolkits, set up
signals and slots, and see which one you like best.



More information about the Python-list mailing list