PyQt6

6.11.0 · active · verified Thu Apr 09

PyQt6 provides Python bindings for the Qt cross-platform application development framework, allowing developers to create desktop applications with native look and feel. It is currently at version 6.11.0 and typically releases new versions in close alignment with the major and minor releases of the underlying Qt library.

Warnings

Install

Imports

Quickstart

This quickstart creates a simple desktop application window with a 'Hello, PyQt6!' label centered within it. It demonstrates the basic structure of a PyQt6 application, including `QApplication` instantiation, creating a `QWidget`, using a layout, and running the event loop.

import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
from PyQt6.QtCore import Qt

class MyWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("My PyQt6 App")
        self.setGeometry(100, 100, 400, 200)

        layout = QVBoxLayout()
        label = QLabel("Hello, PyQt6!", self)
        label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        layout.addWidget(label)
        self.setLayout(layout)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MyWindow()
    window.show()
    sys.exit(app.exec())

view raw JSON →