And finally we reach the end… that is the last of the GUI framework I decided to experiment… pyQt.
PyQt was developed by the Qt Company and is the base for the KDE, one of the desktop environments used by Linux.
Its development started in 1990 and was since it’s beginning a C framework conceived to provide a common abstraction layer able to render a GUI in different platforms. A complete history can be found in the wikipedia article.
Like WxWidgets, Qt is originally conceived to be a C++ framework, but now as many bindings on other languages, like this list. It has ports to almost all operating systems, like Android. Is much probably the most supported GUI framework in different platforms. It started as a GUI framework, but it has grown to be added support for extra stuff like network, mouse, audio, etc. There is a list of all features here.
There are two ports of Qt in Python: PyQt and PySide. The first is the original branch comes from the licensing made by the owner of Qt: the Qt Company. The second was created by Nokia when was the licensee of Qt, since it wanna develop software using a different licensing, but Qt Company refused, and so Nokia forked the framework. The code require minimal modifications in order to use one or another, usually it suffices to change the imports from PyQt
to PySide
.
There is a visual designer for Qt when you can build the GUI from the grounds-up using drag and drop widgets from a tool
bar. QT Designer is free and can be installed along with Qt/PySide.
Qt has a staggering number of widgets, all descending from the basic class QWidget
. Almost everything you need is on those classes, I used a QListView
to build the main panel. For every item in the list there was a QStandardItem
which represents an Icon which is added to a QStandItemModel
which is the model to which you add the items.
Dragging and droping the icons inside and from outside or to inside can be implemented through several drag*
and drop*
methods in the QListView
class. To bind widget events with methods you use the .connect
method to associate them, passing the name of the method to deal with the event.
The program was developed and tested on Windows, and on Mac, because of the separation between icons and executables it required changes to deal with the specificities of each platofrm. There is, the code is not imediatelly portable between platforms.
The source code for this implementation is available at GitHub.