Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of PyQt over PyGTK and vice-versa? [closed]

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 ?
like image 756
Xion345 Avatar asked Jun 15 '12 09:06

Xion345


People also ask

Why PyQt is used?

PyQt is widely used for creating large-scale GUI-based programs. It gives programmers the freedom to create GUIs of their choice while also providing a lot of good pre-built designs. PyQT gives you widgets to create complex GUIs.

Can I use PyQt for free?

No, you must buy a PyQt commercial license for commercial use. A possible alternative is to switch to PySide2, also known as Qt for Python. This comes from the same company as Qt itself, and is licensed under GPL/LGPL/Commercial, also the same as Qt itself. The differences between PyQt and Pyside2 are minor.

Does PyQt require Qt?

You can purchase the commercial version of PyQt here. More information about licensing can be found in the License FAQ. PyQt does not include a copy of Qt. You must obtain a correctly licensed copy of Qt yourself.


2 Answers

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.

like image 197
Oleh Prypin Avatar answered Oct 20 '22 05:10

Oleh Prypin


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.

like image 34
Luke Avatar answered Oct 20 '22 03:10

Luke