blob: 926fff6cd8a7ecf99e5efcee7f3b25d08992b527 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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())
|