PyQt6

Introduction

Qt is a cross-platform application framework for creating Graphical User Interfaces (GUIs), i.e. it run on various software and hardware platforms.

PyQt is the bridge that integrates Qt and the Python programming language, i.e. its a Python wrapper abound the Qt libraries.

Install PyQt6

pip install PyQt6

Definitions

A widget is an element of a Graphical User Interface (GUI) that displays information and provides a way for users to interact with the applications.

Your Very First PyQt6 Program

#!/usr/bin/python3 # =========================================================== # my first Qt application # =========================================================== from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel from PyQt6.QtCore import Qt # ---- which version of Qt am I using? from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR print('Qt:', QT_VERSION_STR, ' PyQt:', PYQT_VERSION_STR) # ---- initialize Qt application app = QApplication([]) # ---- create a Qt window window = QMainWindow() window.setMinimumSize(400,400) window.setWindowTitle('My First Qt Window') # ---- add a text widgets label = QLabel('Hello World!', alignment=Qt.AlignmentFlag.AlignCenter) font = window.font() font.setPointSize(17) font.setBold(True) label.setFont(font) window.setCentralWidget(label) # ---- event loop window.show() app.exec()

Links

PyQt6 vs PySide6 (What's the difference)

Want to create GUI applications with Python?

PyQt Documentation v6.7.1 - Reference Guide

Make GUI Applications In Python With PyQt6 | PyQt6 Tutorial Part 1 (YouTube)

Everything About PyQt6 Layouts! | PyQt6 Tutorial Part 2 (YouTube)