forked from papasmf1/ChatGPTPython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chap10_DemoCheckBox.py
47 lines (39 loc) · 1.45 KB
/
Chap10_DemoCheckBox.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
47
#Chap09_DemoCheckBox.py
import sys
from PyQt5.QtWidgets import *
class DemoWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setupUI()
def setupUI(self):
#x축, y축, width, height를 모두 지정
self.setGeometry(800, 200, 300, 300)
#코드로 CheckBox위젯을 생성
self.checkBox1 = QCheckBox("아이폰", self)
self.checkBox1.move(10, 20)
self.checkBox1.resize(150, 30)
self.checkBox1.stateChanged.connect(self.checkBoxState)
self.checkBox2 = QCheckBox("안드로이드폰", self)
self.checkBox2.move(10, 50)
self.checkBox2.resize(150, 30)
self.checkBox2.stateChanged.connect(self.checkBoxState)
self.checkBox3 = QCheckBox("윈도우폰", self)
self.checkBox3.move(10, 80)
self.checkBox3.resize(150, 30)
self.checkBox3.stateChanged.connect(self.checkBoxState)
self.statusBar = QStatusBar(self)
self.setStatusBar(self.statusBar)
def checkBoxState(self):
msg = ""
if self.checkBox1.isChecked() == True:
msg += "아이폰 "
if self.checkBox2.isChecked() == True:
msg += "안드로이드폰 "
if self.checkBox3.isChecked() == True:
msg += "윈도우폰 "
self.statusBar.showMessage(msg)
if __name__ == "__main__":
app = QApplication(sys.argv)
demoWindow = DemoWindow()
demoWindow.show()
app.exec_()