tobby48 6 gadus atpakaļ
vecāks
revīzija
7b2affef24
1 mainītis faili ar 54 papildinājumiem un 0 dzēšanām
  1. 54
    0
      src/kr/co/swh/lecture/python/pyqt5/checkbox.py

+ 54
- 0
src/kr/co/swh/lecture/python/pyqt5/checkbox.py Parādīt failu

@@ -0,0 +1,54 @@
1
+import sys
2
+from PyQt5.QtWidgets import *
3
+from PyQt5.QtCore import *
4
+from PyQt5.QtGui import *
5
+
6
+class MyWindow(QMainWindow):
7
+    def __init__(self):
8
+        super().__init__()
9
+        self.title = 'SWH Academy Window.'
10
+        self.left = 200
11
+        self.top = 200
12
+        self.width = 360
13
+        self.height = 150
14
+        self.initUI()
15
+
16
+    def initUI(self):
17
+        self.setWindowTitle(self.title)
18
+        self.setGeometry(self.left, self.top, self.width, self.height)
19
+
20
+        self.label = QLabel("", self)
21
+        self.label.move(50, 20)
22
+        self.label.resize(220, 60)
23
+        
24
+        self.radioButton1 = QCheckBox("SWH Academy ", self)
25
+        self.radioButton1.move(20, 90)
26
+        self.radioButton1.setChecked(True)
27
+        self.radioButton1.stateChanged.connect(self.checkBoxState)
28
+        
29
+        self.radioButton2 = QCheckBox("Coding ", self)
30
+        self.radioButton2.move(140, 90)
31
+        self.radioButton2.stateChanged.connect(self.checkBoxState)
32
+        
33
+        self.radioButton3 = QCheckBox("WorldHistory ", self)
34
+        self.radioButton3.move(220, 90)
35
+        self.radioButton3.stateChanged.connect(self.checkBoxState)
36
+        
37
+        self.checkBoxState()
38
+        
39
+    def checkBoxState(self):
40
+        message = ""
41
+        if self.radioButton1.isChecked():
42
+            message += self.radioButton1.text();
43
+        if self.radioButton2.isChecked():
44
+            message += self.radioButton2.text();
45
+        if self.radioButton3.isChecked():
46
+            message += self.radioButton3.text();
47
+            
48
+        self.label.setText(message)
49
+        
50
+if __name__ == "__main__":
51
+    app = QApplication(sys.argv)
52
+    mywindow = MyWindow()
53
+    mywindow.show()
54
+    app.exec_()