|
@@ -1,15 +1,16 @@
|
1
|
1
|
import sys
|
2
|
2
|
from PyQt5.QtWidgets import *
|
3
|
3
|
from PyQt5.QtCore import *
|
|
4
|
+from PyQt5.QtGui import *
|
4
|
5
|
|
5
|
6
|
class MyWindow(QMainWindow):
|
6
|
7
|
def __init__(self):
|
7
|
8
|
super().__init__()
|
8
|
9
|
self.title = 'SWH Academy Window.'
|
9
|
10
|
self.left = 200
|
10
|
|
- self.top = 200
|
11
|
|
- self.width = 360
|
12
|
|
- self.height = 100
|
|
11
|
+ self.top = 100
|
|
12
|
+ self.width = 600
|
|
13
|
+ self.height = 550
|
13
|
14
|
self.initUI()
|
14
|
15
|
|
15
|
16
|
def initUI(self):
|
|
@@ -17,27 +18,38 @@ class MyWindow(QMainWindow):
|
17
|
18
|
self.setGeometry(self.left, self.top, self.width, self.height)
|
18
|
19
|
|
19
|
20
|
self.label = QLabel("", self)
|
20
|
|
- self.label.move(120, 20)
|
21
|
|
- self.label.resize(150, 30)
|
22
|
|
-
|
23
|
|
- self.lineEdit = QLineEdit("", self)
|
24
|
|
- self.lineEdit.move(20, 50)
|
25
|
|
- self.lineEdit.textChanged.connect(self.lineEditChanged)
|
26
|
|
-
|
27
|
|
- button2 = QPushButton("지우기", self)
|
28
|
|
- button2.move(130, 50)
|
29
|
|
- button2.clicked.connect(self.button2Clicked)
|
|
21
|
+ self.label.move(10, 20)
|
|
22
|
+ self.label.resize(580, 460)
|
30
|
23
|
|
31
|
|
- button3 = QPushButton("종료", self)
|
32
|
|
- button3.move(240, 50)
|
33
|
|
- button3.clicked.connect(QCoreApplication.instance().quit)
|
|
24
|
+ self.catImg1 = QPixmap("cat1.jpeg")
|
|
25
|
+ self.catImg2 = QPixmap("cat2.jpg")
|
|
26
|
+ self.catImg3 = QPixmap("cat3.jpg")
|
34
|
27
|
|
35
|
|
- def lineEditChanged(self):
|
36
|
|
- self.label.setText(self.lineEdit.text())
|
|
28
|
+ groupBox = QGroupBox("우리집 고양이들", self)
|
|
29
|
+ groupBox.move(10, 490)
|
|
30
|
+ groupBox.resize(580, 50)
|
|
31
|
+
|
|
32
|
+ self.radioButton1 = QRadioButton("코야", self)
|
|
33
|
+ self.radioButton1.move(20, 500)
|
|
34
|
+ self.radioButton1.setChecked(True)
|
|
35
|
+ self.radioButton1.clicked.connect(self.radioButtonClicked)
|
|
36
|
+ self.radioButtonClicked()
|
|
37
|
+
|
|
38
|
+ self.radioButton2 = QRadioButton("레종", self)
|
|
39
|
+ self.radioButton2.move(130, 500)
|
|
40
|
+ self.radioButton2.clicked.connect(self.radioButtonClicked)
|
|
41
|
+
|
|
42
|
+ self.radioButton3 = QRadioButton("유키", self)
|
|
43
|
+ self.radioButton3.move(240, 500)
|
|
44
|
+ self.radioButton3.clicked.connect(self.radioButtonClicked)
|
37
|
45
|
|
38
|
|
- def button2Clicked(self):
|
39
|
|
- self.label.clear()
|
40
|
|
- self.lineEdit.clear()
|
|
46
|
+ def radioButtonClicked(self):
|
|
47
|
+ if self.radioButton1.isChecked():
|
|
48
|
+ self.label.setPixmap(self.catImg1)
|
|
49
|
+ elif self.radioButton2.isChecked():
|
|
50
|
+ self.label.setPixmap(self.catImg2)
|
|
51
|
+ else:
|
|
52
|
+ self.label.setPixmap(self.catImg3)
|
41
|
53
|
|
42
|
54
|
if __name__ == "__main__":
|
43
|
55
|
app = QApplication(sys.argv)
|