下列pyqt5的代码:class Faceshow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): super(Faceshow, self).__init__(parent) self.setupUi(self) self.main_button.clicked.connect(start) self.main_exit.clicked.connect(self.quit) def quit(self): self.close() class RESUshow(QWidget, Ui_Form): def __int__(self, parent=None): super(RESUshow, self).__init__(parent) self.setupUi(self) img1, img2, text1, text2 = start() pixmap1 = QPixmap.fromImage(img1) pixmap2 = QPixmap.fromImage(img2) self.label_img1.setPixmap(pixmap1) self.label_img2.setPixmap(pixmap2) self.label_psnr.setText(text1) self.label_ssim.setText(text2) 如何在Faceshow主界面槽函数调用start函数后将返回值传入RESUshow窗口的label中RESUshow,并把RESUshow窗口显示出来,主程序怎么实现
时间: 2023-06-16 16:02:41 浏览: 192
撩课-Python-GUI编程-PyQT5代码.zip_gui毕业_pyqt5 GUI_python gui chachong_
在Faceshow主界面槽函数调用start函数后将返回值传入RESUshow窗口的label中,可以先实例化RESUshow类,然后将返回值作为参数传入,最后调用show()方法显示RESUshow窗口。
主程序可以在创建QApplication实例后,先创建Faceshow实例并显示,然后在Faceshow槽函数中创建RESUshow实例并显示。
以下是修改后的代码示例:
```
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
from PyQt5.QtGui import QPixmap
from ui_mainwindow import Ui_MainWindow
from ui_form import Ui_Form
from start import start
class Faceshow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(Faceshow, self).__init__(parent)
self.setupUi(self)
self.main_button.clicked.connect(self.show_resu)
self.main_exit.clicked.connect(self.quit)
def show_resu(self):
img1, img2, text1, text2 = start()
resu_show = RESUshow(img1, img2, text1, text2)
resu_show.show()
def quit(self):
self.close()
class RESUshow(QWidget, Ui_Form):
def __init__(self, img1, img2, text1, text2, parent=None):
super(RESUshow, self).__init__(parent)
self.setupUi(self)
pixmap1 = QPixmap.fromImage(img1)
pixmap2 = QPixmap.fromImage(img2)
self.label_img1.setPixmap(pixmap1)
self.label_img2.setPixmap(pixmap2)
self.label_psnr.setText(text1)
self.label_ssim.setText(text2)
if __name__ == '__main__':
app = QApplication(sys.argv)
faceshow = Faceshow()
faceshow.show()
sys.exit(app.exec_())
```
阅读全文