We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ddbdbec commit 723087bCopy full SHA for 723087b
pyqt-calculator-tutorial/examples/signal_slots.py
@@ -0,0 +1,34 @@
1
+"""Signals and slots example."""
2
+
3
+import sys
4
5
+from PyQt6.QtWidgets import (
6
+ QApplication,
7
+ QLabel,
8
+ QPushButton,
9
+ QVBoxLayout,
10
+ QWidget,
11
+)
12
13
14
+def greet():
15
+ if msgLabel.text():
16
+ msgLabel.setText("")
17
+ else:
18
+ msgLabel.setText("Hello World!")
19
20
21
+app = QApplication([])
22
+window = QWidget()
23
+window.setWindowTitle("Signals and slots")
24
+layout = QVBoxLayout()
25
26
+button = QPushButton("Greet")
27
+button.clicked.connect(greet)
28
29
+layout.addWidget(button)
30
+msgLabel = QLabel("")
31
+layout.addWidget(msgLabel)
32
+window.setLayout(layout)
33
+window.show()
34
+sys.exit(app.exec())
0 commit comments