PySide6

6.11.0 · active · verified Sat Apr 11

PySide6 is the official Python binding for the Qt cross-platform application and UI framework, providing access to the complete Qt 6.0+ framework. It enables Python developers to create robust and visually appealing graphical user interface (GUI) applications for desktop and other platforms. Currently at version 6.11.0, PySide6 is actively maintained by The Qt Company with releases often synchronized with the underlying Qt framework.

Warnings

Install

Imports

Quickstart

This quickstart code creates a basic PySide6 application with a main window, a label displaying 'Hello, PySide6!', and a button. Clicking the button changes the label's text and prints a message to the console. It demonstrates fundamental concepts like QApplication, QMainWindow, widgets, layouts, and signal/slot connections.

import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget, QPushButton
from PySide6.QtCore import Qt

class MyWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('PySide6 Hello World!')
        self.setGeometry(100, 100, 400, 200)

        layout = QVBoxLayout()
        label = QLabel('Hello, PySide6!')
        label.setAlignment(Qt.AlignCenter)
        layout.addWidget(label)

        button = QPushButton('Click Me!')
        button.clicked.connect(self.on_button_click)
        layout.addWidget(button)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)

    def on_button_click(self):
        print('Button clicked!')
        self.centralWidget().findChild(QLabel).setText('You clicked the button!')

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

view raw JSON →