Technical vision for Qt for Python - What lies ahead

qtpy
After our previous post related to the vision of the next major release of Qt, we felt that a paragraph to describe the Qt for Python story was not enough to share all the features and changes we have been considering for future releases.

Transition to Qt 6

Exposing a huge framework such as Qt to another language is not an easy task and this was the main reason for the slow porting from the old PySide version in Qt 4 to Qt 5.
Many developers hours were spent in adapting to new Qt 5 APIs, and more importantly, the binding generator tool such that everything can be handled properly.

Now with Qt 6 things will be different, because the development of Qt for Python is progressing side-by-side to the C++ and QML stories in Qt 6. Hopefully, there will be a lot fewer surprises this time around. In fact, this effect can be seen with current 5.x releases, PySide2 is available almost at the same time as the Qt release, having in some cases a few days delays.

Since the official release in Qt 5.12.0, the downloads of Qt for Python has been increasing day-by-day, which translates on the community adopting and enjoying the project.

pyside_download_since_512

PyPi Downloads since the release of the first stable version 5.12.0

Why we are developing Qt for Python?

The first lines of code which later evolved into the first Qt release date back to the early 90s, which coincidentally are roughly the same dates for the birth of Python.
Both projects started out with the mindset, among other things, to make the developer's life easier.
The combination of both projects was always a good idea, and we have been seeing a great evolution of the Qt for Python community since the official release of PySide.

We cannot fool ourselves and not take into account the other set of Qt bindings for Python out there, PyQt.
Since the beginning of PySide, we have been trying to keep source compatibility with PyQt code. The PyQt users have also been supporting PySide, claiming that the main difference is mostly changing the import name. This makes the people behind the Qt for Python project really grateful.
Both sets of bindings are quite mature, but we want to move one step further. Indeed we have taken some deviating decisions already like not exposing QVariant and other things.

At the moment we have the following highlights for the two types of developers who use Qt for Python:

C++ developers

  • Fast prototyping: considering the requirements of certain projects, it is really handy to have a quick way of prototyping an idea without setting up too many things. Often they are just one pip install pyside2  call away. If after some iterations the application really needs a more performant behavior or a strongly typed language, the transition of the code to C++ will be straightforward.

    Writing an example application with PySide2

  • Embedding Python: an existing application could be extended by using Python, maybe via an add-ons/plug-in system, or even by having an embedded interpreter to manipulate other aspects of the application.
    qtforpython-scriptableapplication

    Qt/C++ Application that has an embedded Python interpreter that execute the code written on the text field, being able to modify the Qt/C++ application itself.

Python developers

  • A robust framework for GUI development: there are many options to create graphical user interfaces with Python, but Qt provides a complete and robust framework that has been proven to fulfill most requirements for a nice GUI. We have been keeping track of other modules to contribute and also to get good ideas what we could include in the next releases.

    PySide2 installation process

  • Binding generation: creating Python modules could be a difficult task, and at the moment many projects are trying to provide a simple interface to achieve this. Shiboken is getting more and more momentum to be able to handle any C++ project. Due to the experience of many costumers and users, our tool is sufficient to provide Python bindings for existing C++ projects. See for example what Gamry Instruments already did.

    Creating an example "Hello World" module with Shiboken.

The future of Qt for Python

We have been gathering many ideas since we made the first official Qt for Python/Pyside2 release.

A couple of highlights are:

  • Naming, many times the versioning of the module generated confusion for our users since it was an independent numbering compared to Python and Qt. Therefore we have decided to follow the Qt versioning from Qt6 onwards. The name itself will remain, hence the release will be PySide 6.
  • Python2 support, from the beginning of 2020 Python2 will be no longer maintained, we decided to do the same and once PySide6 is released we will be dropping support for it. Internally this will solve many issues we currently have handling Python2 and Python3 at the same time.
  • Pythonization, exposing a C++ API to a Python module can cause programmers to get a strange feeling while writing an application. We would like to go one step further and try to eliminate boilerplate code and provide a complementary python alike API.
  • Tooling, having a separate set of tools for uic and rcc made little sense because we needed to keep track of all the changes in the official tools and port them to our variants. It appears to be better to integrate Python into the official tools. Hopefully, starting with PySide2 5.14 we will be directly able to use Qt's uic and rcc, instead of the python wrappers.
  • Meta Widgets and utilities, in favor of a quick-development we are trying to write a set of utilities and widgets which would make the life of Python developers easier. Out-of-the-box integration with modules like NumPy, Pandas, and others, are in our priority list too.
  • Shiboken, adapting all the new features which Qt6 will include will be our main focus. Luckily we have been getting more contributors submitting bug fixes and new features. Subsequently, it is just a matter of time getting a even more mature Shiboken release.

You can read about the more complete list on JIRA (PYSIDE-904), which we will love to have available in Qt 6 (we will do our best, we promise ☺).

We truly thank the Qt for Python community. Most of the features we are currently working on came from them. With that in mind, we would like to encourage you to communicate your concerns and ideas on our IRC channel #qt-pyside. We would love to hear what you think, and how we can make Qt for Python better.


Blog Topics:

Comments