-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSample3_Signles_and_Slots.py
46 lines (39 loc) · 1.2 KB
/
Sample3_Signles_and_Slots.py
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
44
45
46
import sys
from PyQt5 import QtWidgets, QtGui
class window(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.start()
def start(self):
self.setWindowTitle("Sample3")
self.setGeometry(100,100,300,130)
self.setStyleSheet("QWidget {background-color: gray}")
self.ui_setup()
self.show()
def ui_setup(self):
self.l1 = QtWidgets.QLabel(self)
self.l1.setPixmap(QtGui.QPixmap("logo.png"))
self.l2 = QtWidgets.QLabel(self)
self.l2.setText("Hello World")
self.b1 = QtWidgets.QPushButton(self)
self.b1.setText("Button")
self.b1.setStyleSheet("QPushButton {background-color: white}")
self.b1.clicked.connect(self.b1_clicked)
self.h1_box = QtWidgets.QHBoxLayout()
self.h1_box.addStretch()
self.h1_box.addWidget(self.l1)
self.h1_box.addStretch()
self.h2_box = QtWidgets.QHBoxLayout()
self.h2_box.addStretch()
self.h2_box.addWidget(self.l2)
self.h2_box.addStretch()
self.v_box = QtWidgets.QVBoxLayout()
self.v_box.addLayout(self.h1_box)
self.v_box.addLayout(self.h2_box)
self.v_box.addWidget(self.b1)
self.setLayout(self.v_box)
def b1_clicked(self):
self.l2.setText("I have been clicked")
app = QtWidgets.QApplication(sys.argv)
w = window()
sys.exit(app.exec_())