Using QT with Python for developing GUI
QT is a popular toolkit to develop GUIs. I was curious to see how it works with Python. Here are the basics:
From doc.qt.io: “Qt for Python offers Python bindings for Qt, enabling the use of Qt5 APIs in Python applications. It lets Python developers utilize the full potential of Qt, using the PySide2 module.”
Installation: https://doc.qt.io/qtforpython/gettingstarted.html
We need: Python 3.5+ and Clang 6.0+. The above step requires that you install clang. To do this, follow these step:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
sudo apt-get update
sudo apt-get install -y clang-7
In the above, I am installing clang 7 on Ubuntu 16.04. For other versions of clang or Ubuntu, substitute the link in line 2 with the right one from: https://apt.llvm.org
Now, we do:
sudo pip install PySide2
And the install should complete. To test,
from PySide2 import QtCore def printQtCoreVersion(QtCoreHandle): ver = QtCoreHandle.__version_info__ print("QtCore Version = %d.%d.%d"%ver) printQtCoreVersion(QtCore)
Should output (Depending on your version):
QtCoreVersion = 5.12.2

