12

I have an application whose GUI is to be remade for ergonomic reasons. It was written in PyGTK and I am wondering if I should switch to PyQt to ease future developments or not.

This application has a mostly classical UI with buttons, toolbars, dialogs etc. but also has some specific requirements : I will certainly need to create a custom widget based on treeview/tableview (to make a spreadsheet-like widget) and this application has a lot of worker threads which update the GUI.

I am seeking advice on these two points :

  • As regards the creation custom widgets, does PyQt provide better mechanisms than PyGTK, especially to slightly modify existing widgets.
  • I had problems with (even when properly using threads_init() and threads_enter()) the updating of the GUI by worker threads while using PyGTK. Is PyQt any better on that point ?
Xion345
  • 1,627
  • 12
  • 26
  • 2
    Well, for one thing PyGTK is no longer actively developed. [PyGObject](https://live.gnome.org/PyGObject) is apparently the way to do things now. – Henry Gomersall Jun 15 '12 at 09:55
  • An update from a worker thread works always with `gobject.idle_add`. `threads_init` is not supported on Windows. This might be the problem? – schlamar Jun 15 '12 at 10:27

5 Answers5

3

I like GTK+ best, since (at least to me) it looks nicer. PyQt and variants (e.g. PySide), however, do have an immensely large set of extras, including a WebKit engine, an XML parser, SQL support, and more.

If you just want looks, I'd say GTK+/PyGObject. If you are plannning on using anything PyQt has, use PyQt.

As a side note, if you stick with GTK+, I'd advise you to upgrade to PyGObject and GTK+ 3.0, since PyGtk+ is no longer maintained.

kirbyfan64sos
  • 10,377
  • 6
  • 54
  • 75
1

I can't compare, because I don't use GTK, but I'd suggest Qt.

Qt definitely has "treeview/tableview" you're talking about and you can make the "cells" your custom widgets (I'm just studying this topic right now). Qt was made with a lot of thought about threads, so worker threads can use the signal/slot mechanism with ease. And yes, you can modify the existing widgets by applying stylesheets or subclassing.

Now about PyQt, I wouldn't recommend it because of licensing issues. PySide seems like a better Qt→Python binding to me: it can be used in commercial applications freely and has a few tiny advantages in the API (but otherwise it's fully compatible with PyQt).

Qt is cross-platform and deployment of PySide applications is very easy with cx_Freeze; users of your application won't have to install anything at all.

Oleh Prypin
  • 33,184
  • 10
  • 89
  • 99
  • 2
    Just to be contrary, I'll recommend PyQt over Pyside because Pyside is a newer project and still tends to be a bit more buggy in my experience. The APIs for the two libraries are nearly identical, though, so it shouldn't be too much effort to switch between them if you change your mind. – Luke Aug 03 '12 at 22:01
  • 1
    @Luke I always try to `import PySide` first and on `ImportError` `import PyQt4` (not sure what the licensing consequences will be), and make my applications work with Python 3 and Python 2, all with one codebase. – Oleh Prypin Aug 03 '12 at 22:03
  • 1
    I'd also recommend PyQt over PySide if you don't need LGPL. PyQt is a much more mature project, and has a highly competant and pro-active maintainer. I have also found PySide to be significantly more buggy, although I will admit that I haven't used it much recently, so things may have changed in that regard. – ekhumoro Aug 04 '12 at 17:32
  • main difference between PyQT and PyGTK is that PyQT is a bundle of all you need to do a graphical applications in one library whereas PyGTK you need to find out which library goes with which version for each component which is cubersome if you need extra features not found in PyGTK itself. – amirouche Sep 26 '12 at 15:31
1

I also have no experience with GTK, but can offer some answers nevertheless:

  • Qt is designed from the ground up to be object-oriented; almost everything in it has excellent support for subclassing. PyQt likewise.

  • Qt explicitly does NOT support modification of the GUI by any threads other than the main GUI thread. You're likely to cause crashes this way. As BlaXpirit mentioned, though, there are a variety of very easy inter-thread communication mechanisms such as signal passing.

Luke
  • 11,374
  • 2
  • 48
  • 61
1

Definitely PyQt... There are a lot of advanced applications using it... Personally, I'm using KDE, so, even my system's GUI uses Qt! I'm also creating a spreadsheet application and I find that it's far easier that what I thought at first... But, BiaXpirit is also right: except if you're developing an open-source app, maybe you should use PySide or something else...

Antoni4040
  • 2,297
  • 11
  • 44
  • 56
1

I also never used PyGTK but I think the two features of Qt that are exceptionally good are: model/view programming and signal/slots. If you need that kind of stuff I would say that it's worth at least reading the docs about them and compare the two toolkits with that respect.

The designer is such a time saver also. The promotion feature---you can your custom widgets in the designer replacing it visually with something similar, e.g you have implemented a custom tree view with your functions--- is just very convenient. You can use the designer to display a regular tree view but when you export it uses your custom class.

The docs are superb.

Edit: You can use Qt docs directly. I've been programming in python using PySide and there are only a few instances I actually needed specific documentation. Although it exists.