소스 검색

lineEdit add

tobby48 6 년 전
부모
커밋
6954cdaf91
1개의 변경된 파일46개의 추가작업 그리고 0개의 파일을 삭제
  1. 46
    0
      src/kr/co/swh/lecture/python/pyqt5/lineedit.py

+ 46
- 0
src/kr/co/swh/lecture/python/pyqt5/lineedit.py 파일 보기

@@ -0,0 +1,46 @@
1
+import sys
2
+from PyQt5.QtWidgets import *
3
+from PyQt5.QtCore import *
4
+
5
+class MyWindow(QMainWindow):
6
+    def __init__(self):
7
+        super().__init__()
8
+        self.title = 'SWH Academy Window.'
9
+        self.left = 200
10
+        self.top = 200
11
+        self.width = 360
12
+        self.height = 100
13
+        self.initUI()
14
+
15
+    def initUI(self):
16
+        self.setWindowTitle(self.title)
17
+        self.setGeometry(self.left, self.top, self.width, self.height)
18
+
19
+        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)
30
+        
31
+        button3 = QPushButton("종료", self)
32
+        button3.move(240, 50)
33
+        button3.clicked.connect(QCoreApplication.instance().quit)
34
+
35
+    def lineEditChanged(self):
36
+        self.label.setText(self.lineEdit.text())
37
+
38
+    def button2Clicked(self):
39
+        self.label.clear()
40
+        self.lineEdit.clear()
41
+        
42
+if __name__ == "__main__":
43
+    app = QApplication(sys.argv)
44
+    mywindow = MyWindow()
45
+    mywindow.show()
46
+    app.exec_()