Deploying PyQt5 in Python Applications

If your computer is not python installed, you must install it. You can install via link.
PyQt5 Installation
Finally we get to install the PyQt5 module.
Start by downloading the tar.gz file, in this case PyQt-gpl-5.5.1.tar.gz
, and extracting it:
1 2 3 4 5 6 7 |
$ tar -xvf PyQt-gpl-5.5.1.tar.gz $ cd PyQt-gpl-5.5.1 $ python3 configure.py --destdir ~/.venv/qtproject/lib/python3.4/site-packages --qmake /opt/qt/5.6/clang_64/bin/qmake $ make $ sudo make install $ sudo make clean |
All Done!
At this point, everything is successfully installed! Now let’s check if everything works by importing PyQt5
from Python 3.4:
1 2 |
$ ~/.venv/qtproject/bin/python3 -c "import PyQt5" |
And just for the sake of it, let’s build a simple hello world Qt application:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
rom PyQt5.QtWidgets import QApplication, QWidget, QLabel if __name__ == "__main__": app = QApplication() # Build the window widget x = QWidget() x.setGeometry(300, 300, 250, 150) x.setWindowTitle("My First App") label = QLabel("Hello World", x) label.setToolTip("This is a <b>Label</b> widget with Tooltip") label.resize(label.sizeHint()) label.move(60, 30) # Show window and run x.show() app.exec_() |
if you have question do not forget to write from the chat button next to it or from the comment
Recent Comments