打开跳转界面

import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5 import QtCore


################################################
#######创建主窗口
################################################
class FirstMainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('主界面')

        ###### 创建界面 ######
        self.centralwidget = QWidget()
        self.setCentralWidget(self.centralwidget)
        self.Layout = QVBoxLayout(self.centralwidget)

        # 设置顶部三个按钮
        self.topwidget = QWidget()
        self.Layout.addWidget(self.topwidget)
        self.buttonLayout = QHBoxLayout(self.topwidget)

        self.pushButton1 = QPushButton()
        self.pushButton1.setText("结果展示")
        self.buttonLayout.addWidget(self.pushButton1)

        self.pushButton2 = QPushButton()
        self.pushButton2.setText("打开对话框")
        self.buttonLayout.addWidget(self.pushButton2)

        self.pushButton3 = QPushButton()
        self.pushButton3.setText("打开提示框")
        self.buttonLayout.addWidget(self.pushButton3)

        # 设置中间文本
        self.label = QLabel()
        self.label.setText("图像去模糊算法")
        self.label.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setFont(QFont("Roman times", 50, QFont.Bold))
        self.Layout.addWidget(self.label)

        # 设置状态栏
        self.statusBar().showMessage("当前用户:sun")

        # 窗口最大化
        self.setFixedSize(960,700)

        ###### 三个按钮事件 ######
        self.pushButton1.clicked.connect(self.on_pushButton1_clicked)
        self.pushButton2.clicked.connect(self.on_pushButton2_clicked)
        self.pushButton3.clicked.connect(self.on_pushButton3_clicked)

    # 按钮一:打开主界面
    windowList = []

    def on_pushButton1_clicked(self):
        the_window = SecondWindow()
        self.windowList.append(the_window)  ##注:没有这句,是不打开另一个主界面的!
        self.close()
        the_window.show()

    # 按钮二:打开对话框
    def on_pushButton2_clicked(self):
        the_dialog = TestdemoDialog()
        if the_dialog.exec_() == QDialog.Accepted:
            pass

    # 按钮三:打开提示框
    def on_pushButton3_clicked(self):
        QMessageBox.information(self, "提示", "点击结果展示按钮就可以得到图片去模糊的结果")
        # QMessageBox.question(self, "提示", "这是question框!")
        # QMessageBox.warning(self, "提示", "这是warning框!")
        # QMessageBox.about(self, "提示", "这是about框!")


################################################
#######第二个主界面
################################################
class SecondWindow(QMainWindow):

    def __init__(self):
        super(QMainWindow, self).__init__()
        self.setWindowTitle('图像去模糊结果')
        self.resize(800, 800)
        # 新建一个QWebEngineView()对象
        self.qwebengine = QWebEngineView(self)
        # 设置网页在窗口中显示的位置和大小
        self.qwebengine.setGeometry(20, 20, 1800, 1800)
        # 在QWebEngineView中加载网址
        self.qwebengine.load(QUrl(
            r"http://localhost:63342/Deblurgan/Deblurgan/results/experiment_name/test_400/index.html?_ijt=vfr7g8e74rceruamhhg7o81fdj&_ij_reload=RELOAD_ON_SAVE"))
        # 设置状态栏
        self.statusBar().showMessage("当前用户:sun")

        # 窗口最大化
        self.setFixedSize(960, 700)

    ###### 重写关闭事件,回到第一界面
    windowList = []

    def closeEvent(self, event):
        the_window = FirstMainWindow()
        self.windowList.append(the_window)  ##注:没有这句,是不打开另一个主界面的!
        the_window.show()
        event.accept()


################################################
#######对话框
################################################
class TestdemoDialog(QDialog):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('对话框')

        ### 设置对话框类型
        self.setWindowFlags(Qt.Tool)



################################################
#######程序入门
################################################
if __name__ == "__main__":
    app = QApplication(sys.argv)
    the_mainwindow = FirstMainWindow()
    the_mainwindow.show()
    sys.exit(app.exec_())

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值