diff options
| author | afix.space <laurent@afix.space> | 2026-07-09 19:34:22 +0200 |
|---|---|---|
| committer | afix.space <laurent@afix.space> | 2026-07-09 19:34:22 +0200 |
| commit | 5c369a5d98dbab80903dfcb7c52625c78228e789 (patch) | |
| tree | e17ac19cc282778dd14aa6cdac3b50481e55e9ea /examples | |
Flake devShell (PySide6 6.11 on Python 3.13, designer, uic/rcc from
qtbase libexec, offline docs) plus hello_widgets and hello_quick
examples. QML_IMPORT_PATH exported — nixpkgs PySide6 finds platform
plugins on its own but not QML imports; see README.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/Main.qml | 26 | ||||
| -rw-r--r-- | examples/hello_quick.py | 22 | ||||
| -rw-r--r-- | examples/hello_widgets.py | 43 |
3 files changed, 91 insertions, 0 deletions
diff --git a/examples/Main.qml b/examples/Main.qml new file mode 100644 index 0000000..ed85a81 --- /dev/null +++ b/examples/Main.qml @@ -0,0 +1,26 @@ +import QtQuick +import QtQuick.Controls + +ApplicationWindow { + visible: true + width: 320 + height: 200 + title: "Hello PySide6 Quick" + + property int count: 0 + + Column { + anchors.centerIn: parent + spacing: 12 + + Text { + text: "Clics : " + count + anchors.horizontalCenter: parent.horizontalCenter + } + + Button { + text: "Cliquer" + onClicked: count++ + } + } +} diff --git a/examples/hello_quick.py b/examples/hello_quick.py new file mode 100644 index 0000000..0ffa9f2 --- /dev/null +++ b/examples/hello_quick.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +"""Minimal PySide6 Qt Quick app: loads Main.qml next to this script.""" + +import sys +from pathlib import Path + +from PySide6.QtGui import QGuiApplication +from PySide6.QtQml import QQmlApplicationEngine + + +def main() -> int: + app = QGuiApplication(sys.argv) + + engine = QQmlApplicationEngine() + engine.objectCreationFailed.connect(lambda: sys.exit(1)) + engine.load(Path(__file__).parent / "Main.qml") + + return app.exec() + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/examples/hello_widgets.py b/examples/hello_widgets.py new file mode 100644 index 0000000..926fff6 --- /dev/null +++ b/examples/hello_widgets.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"""Minimal PySide6 Widgets app: a counter demonstrating signals/slots.""" + +import sys + +from PySide6.QtWidgets import ( + QApplication, + QLabel, + QPushButton, + QVBoxLayout, + QWidget, +) + + +def main() -> int: + app = QApplication(sys.argv) + + window = QWidget() + window.setWindowTitle("Hello PySide6") + + label = QLabel("Clics : 0") + button = QPushButton("Cliquer") + + count = 0 + + def on_click() -> None: + nonlocal count + count += 1 + label.setText(f"Clics : {count}") + + button.clicked.connect(on_click) + + layout = QVBoxLayout(window) + layout.addWidget(label) + layout.addWidget(button) + + window.resize(240, 100) + window.show() + return app.exec() + + +if __name__ == "__main__": + sys.exit(main()) |
