Skip to content

Commit 723087b

Browse files
committed
Add new example
1 parent ddbdbec commit 723087b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)