Skip to content

Commit e96def3

Browse files
committed
Add signals, and slots example
1 parent 981822f commit e96def3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# filename: signals_slots.py
2+
3+
"""Signals, and Slots example."""
4+
5+
import sys
6+
7+
from PyQt5.QtWidgets import QApplication
8+
from PyQt5.QtWidgets import QWidget
9+
from PyQt5.QtWidgets import QPushButton
10+
from PyQt5.QtWidgets import QLabel
11+
from PyQt5.QtWidgets import QVBoxLayout
12+
13+
14+
def greeting():
15+
msg.setText('Hello World!')
16+
17+
18+
app = QApplication(sys.argv)
19+
window = QWidget()
20+
window.setWindowTitle('Signals, and Slots')
21+
layout = QVBoxLayout()
22+
btn = QPushButton('Greet')
23+
btn.clicked.connect(greeting)
24+
layout.addWidget(btn)
25+
msg = QLabel('')
26+
layout.addWidget(msg)
27+
window.setLayout(layout)
28+
window.show()
29+
sys.exit(app.exec_())

0 commit comments

Comments
 (0)