"""login,hello,cal为三个ui文件生成的py文件"""
from login import Ui_MainWindow as login_ui
from hello import Ui_MainWindow as hello_ui
from cal import Ui_MainWindow as cal_ui
from PyQt5 import QtCore,QtWidgets
import sys
class MainWin(QtWidgets.QMainWindow,login_ui):
#自定定义两个信号
switch1 = QtCore.pyqtSignal() # cal
switch2 = QtCore.pyqtSignal() # hello
def __init__(self):
super(MainWin, self).__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.go_cal)
self.pushButton_2.clicked.connect(self.go_heelo)
def go_cal(self):
self.switch1.emit()
def go_heelo(self):
self.switch2.emit()
class cal(QtWidgets.QMainWindow,cal_ui):
def __init__(self):
super(cal,self).__init__()
self.setupUi(self)
class hello(QtWidgets.QMainWindow,hello_ui):
switch3=QtCore.pyqtSignal()
def __init__(self):
super(hello,self).__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.go_login)
def go_login(self):
self.switch3.emit()
#实现多个页面跳转的控制器
class controler:
def __init__(self):
self.login = MainWin()
self.calendar=cal()
self.hello=hello()
def show_login(self):
self.login.switch1.connect(self.show_cal)
self.login.switch2.connect(self.show_helo)
self.hello.close()
self.calendar.close()
self.login.show()
def show_cal(self):
self.login.close()
self.calendar.show()
def show_helo(self):
self.login.close()
self.hello.show()
self.hello.switch3.connect(self.show_login)
if __name__=="__main__":
app=QtWidgets.QApplication(sys.argv)
main=controler()
main.show_login()
sys.exit(app.exec_())
pyqt5实现多窗口跳转
最新推荐文章于 2023-11-28 16:20:33 发布