diff options
Diffstat (limited to 'examples/hello_widgets.py')
| -rw-r--r-- | examples/hello_widgets.py | 43 |
1 files changed, 43 insertions, 0 deletions
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()) |
