-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiple_window_example
115 lines (80 loc) · 3.18 KB
/
multiple_window_example
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_Form1(object):
# switch_window = QtCore.pyqtSignal(str)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(408, 317)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(140, 180, 113, 32))
self.pushButton.setObjectName("pushButton")
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(100, 30, 201, 71))
self.label.setObjectName("label")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
# self.pushButton.clicked.connect(self.pushbutton_handler)
# def pushbutton_handler(self):
# self.openwindow()
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "Back"))
self.label.setText(_translate("Form", "Page 1"))
class Ui_Form(object):
# switch_window = QtCore.pyqtSignal(str)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(522, 355)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(140, 10, 191, 51))
self.label.setStyleSheet("font: 36pt \".SF NS Text\";")
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(190, 160, 113, 32))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
# self.pushButton.clicked.connect(self.pushbutton_handler)
# def pushbutton_handler(self):
# self.switch_window.emit()
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "Main Page"))
self.pushButton.setText(_translate("Form", "Next"))
class Login(QtWidgets.QWidget, Ui_Form):
switch_window = QtCore.pyqtSignal()
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setupUi(self)
self.pushButton.clicked.connect(self.pushbutton_handler)
def pushbutton_handler(self):
self.switch_window.emit()
class MainWindow(QtWidgets.QWidget, Ui_Form1):
switch_window = QtCore.pyqtSignal()
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setupUi(self)
self.pushButton.clicked.connect(self.pushbutton_handler)
def pushbutton_handler(self):
self.switch_window.emit()
class Controller:
def __init__(self):
pass
def show_login(self):
self.login = Login()
self.login.switch_window.connect(self.show_main)
self.login.show()
def show_main(self):
self.window = MainWindow()
self.window.switch_window.connect(self.show_login)
self.login.close()
self.window.show()
def main():
app = QtWidgets.QApplication(sys.argv)
controller = Controller()
controller.show_login()
sys.exit(app.exec_())
if __name__ == '__main__':
main()