-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
42 lines (32 loc) · 955 Bytes
/
main.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
from PyQt5.QtWidgets import QWidget, QFormLayout, QApplication, QLabel
from pyqt_switch import PyQtSwitch
class Widget(QWidget):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.__label = QLabel()
self.__label.setText('No')
switch = PyQtSwitch()
switch.toggled.connect(self.__toggled)
switch.setAnimation(True)
# switch.setChecked(True)
# switch.setCircleDiameter(40)
# if switch.isChecked():
# print('Yes')
# else:
# print('No')
lay = QFormLayout()
lay.addRow(self.__label, switch)
self.setLayout(lay)
def __toggled(self, f):
if f:
self.__label.setText('Yes')
else:
self.__label.setText('No')
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
example = Widget()
example.show()
app.exec_()