What is PyQt?

PyQt is a set of Python binding for the Qt Framework from C++ that can be used to create Desktop Graphical User InterfacesGUIs. PyQt gives you all the complex functionalities of C++ Qt while allowing swift development in Python.

Usage

PyQt is widely used for creating large-scale GUI-based programs. It gives programmers the freedom to create GUIs of their choice while also providing a lot of good pre-built designs.

PyQt is used for building GUIs

PyQT gives you widgets to create complex GUIs. In fact, everything in PyQT (buttons, input fields, checkboxes, and Radio boxes) is a widget.

Installing

PyQt can be installed using the following command:

pip install PyQt5

Here is a simple PyQT program you can use to create a window that contains a button widget:

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()
layout.addWidget(QPushButton('first-button'))
window.setLayout(layout)
window.show()
app.exec()

The resulting GUI will look like:

QT Designer

PyQT also comes with a GUI Builder, called QT Designer, that makes designing and creating GUIs much easier. GUIs can easily be designed with QT designer, and their logic can be programmed using PyQT – this makes development faster and easier and gives PyQt an edge (compared to alternatives like Tkinter).