Browse Source

pushbutton update

tobby48 6 years ago
parent
commit
908caca85c

+ 0
- 7
src/kr/co/swh/lecture/python/pyqt5/event-slot.py View File

@@ -1,7 +0,0 @@
1
-import sys
2
-from PyQt5.QtWidgets import *
3
-
4
-app = QApplication(sys.argv)
5
-button = QPushButton('Hello World!')
6
-button.show()
7
-app.exec_()

+ 7
- 23
src/kr/co/swh/lecture/python/pyqt5/pushbutton.py View File

@@ -1,23 +1,7 @@
1
-import sys
2
-from PyQt5.QtWidgets import *
3
-
4
-class MyWindow(QMainWindow):
5
-    def __init__(self):
6
-        super().__init__()
7
-        self.initUI()
8
-        
9
-    def initUI(self):
10
-        self.setWindowTitle("SWH")
11
-
12
-        button = QPushButton("눌러봐", self)
13
-        button.move(50, 30)
14
-        button.clicked.connect(self.click)
15
-
16
-    def click(self):
17
-        QMessageBox.about(self, "메세지 박스", "눌렀어요.")
18
-
19
-if __name__ == "__main__":
20
-    app = QApplication(sys.argv)
21
-    mywindow = MyWindow()
22
-    mywindow.show()
23
-    app.exec_()
1
+import sys
2
+from PyQt5.QtWidgets import *
3
+
4
+app = QApplication(sys.argv)
5
+button = QPushButton('Hello World!')
6
+button.show()
7
+app.exec_()

+ 6
- 4
src/kr/co/swh/lecture/python/pyqt5/pushbutton2.py View File

@@ -1,6 +1,5 @@
1 1
 import sys
2 2
 from PyQt5.QtWidgets import *
3
-from PyQt5.QtCore import *
4 3
 
5 4
 class MyWindow(QMainWindow):
6 5
     def __init__(self):
@@ -12,10 +11,13 @@ class MyWindow(QMainWindow):
12 11
 
13 12
         button = QPushButton("눌러봐", self)
14 13
         button.move(50, 30)
15
-        button.clicked.connect(QCoreApplication.instance().quit)
14
+        button.clicked.connect(self.click)
15
+
16
+    def click(self):
17
+        QMessageBox.about(self, "메세지 박스", "눌렀어요.")
16 18
 
17 19
 if __name__ == "__main__":
18 20
     app = QApplication(sys.argv)
19
-    mywindow = MyWindow()
20
-    mywindow.show()
21
+    window = MyWindow()
22
+    window.show()
21 23
     app.exec_()

+ 21
- 0
src/kr/co/swh/lecture/python/pyqt5/pushbutton3.py View File

@@ -0,0 +1,21 @@
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.initUI()
9
+        
10
+    def initUI(self):
11
+        self.setWindowTitle("SWH")
12
+
13
+        button = QPushButton("눌러봐", self)
14
+        button.move(50, 30)
15
+        button.clicked.connect(QCoreApplication.instance().quit)
16
+
17
+if __name__ == "__main__":
18
+    app = QApplication(sys.argv)
19
+    window = MyWindow()
20
+    window.show()
21
+    app.exec_()