DEV Community

jones268
jones268

Posted on

PyQt5: The Quick and Easy Guide

PyQt5 is a software toolkit for creating graphical user interfaces (GUIs) for Python programs. Written in Python, it runs on Linux, Windows and Mac OS X. It uses the Qt framework, which is written in C++. PyQt5 is released under the GPLv3.

PyQt5 is an updated version of the original PyQt toolkit. PyQt4 was written for Qt 4 but has continued to work with Qt 5 for the most part.

However, some features of Qt 5, such as Qt Quick, are not supported by PyQt4 and so were not included in PipyQt4. The new PyQt5 inherits all of PyQt4’s features while adding support for these new features.

If you are new to Python PyQt, I recommend this course

Hello world

The Qt widget library lets application developers create rich GUI applications for the desktop and a variety of mobile devices.

The Python bindings for Qt are provided by the package PyQt5. In this tutorial, you will learn how to start using Python to develop GUI applications that use the Qt widget library.

You will need to have Python 3.6 or later installed on your computer before you begin. If you don’t, please go here for details about downloading and installing Python 3 on your computer.

All of the basics should be the same for other OSes. You can find the tutorial here.

pyqt hello world

The first step is to install QT5.

The next steps are to install PyQt5 and set it up to use with Python 3.4. I recommend installing PyQt5 like so:

pip3 install PyQt5
Enter fullscreen mode Exit fullscreen mode

You can then run the code below to try it out:

import sys

from PyQt5.QtWidgets import QApplication, QWidget

if __name__ == '__main__':
    app = QApplication(sys.argv)

    w = QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Hello World')
    w.show()

    sys.exit(app.exec_())
Enter fullscreen mode Exit fullscreen mode

PyQt comes with many widgets like buttons, tabs, sliders, images and lots of others.

Top comments (0)