pyqt5中designer页面跳转
页面跳转效果图、效果视频
pyqt5的页面跳转
点击以下图中选项即可跳转不同界面
页面设计
用 Qt designer 设计好了三个页面:interface.py、jiance.py、shebei.py
interface.py 中有一个 Id 为 pushButton_shebei的按钮,用于跳转到 shebei.py 窗口
interface.py 中还有一个 Id 为 pushButton_jiance的按钮,用于跳转到 jiance.py 窗口
跳转相关代码
页面设计中页面的引用
from interfaceUi import *
from PyQt5.QtWidgets import *
from shebeiUi import *
import sys
import Exception
import shebeidemo
import Frist
页面里面的相关代码,通过自己定义函数,在self.ui.pushButton_jiance.clicked.connect(self.函数名)调用函数。实现跳转
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint) # 消除周边的框框
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
# 设置阴影
# 设置跳转
self.ui.pushButton_shebei.clicked.connect(self.shebei)#self+自己设置的名字
self.ui.pushButton_jiance.clicked.connect(self.jiance)
self.ui.pushButton_data.clicked.connect(self.data)
self.ui.pushButton_logout.clicked.connect(self.log_out)
self.show()
#自己定义的函数名
def jiance(self):
# self.close()
self.yushi = Frist.YushiForm()#页面跳转Frist中定义的YushiForm类中
self.yushi.show()#页面展示
def shebei(self):
# self.close()
self.shebei = shebeidemo.shebeiDemo()
self.shebei.show()
def data(self):
self.data = Exception.ExceptionWindow()
self.data.show()
def setup_ui(self):
self.setupUi(self)
# self.setdate()
self.currentSmokeValue()
、
if __name__ == '__main__':
app = QApplication(sys.argv)
mywindow1 = MainWindow()
mywindow1.show()
sys.exit(app.exec_())