ui文件转换为py文件之后
时间: 2023-12-16 09:06:16 浏览: 86
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QDialog
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(679, 379)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(480, 100, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(480, 210, 75, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.images = QtWidgets.QLabel(Dialog)
self.images.setGeometry(QtCore.QRect(40, 60, 171, 251))
self.images.setText("")
self.images.setPixmap(QtGui.QPixmap("D:/111.png"))
self.images.setScaledContents(True)
self.images.setObjectName("images")
self.labels = QtWidgets.QLabel(Dialog)
self.labels.setGeometry(QtCore.QRect(250, 60, 171, 251))
self.labels.setText("")
self.labels.setPixmap(QtGui.QPixmap("../yolov5-master/val_batch1_pred.jpg"))
self.labels.setScaledContents(True)
self.labels.setObjectName("labels")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(40, 20, 101, 16))
font = QtGui.QFont()
font.setFamily("Bahnschrift")
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.label_2.setTextFormat(QtCore.Qt.PlainText)
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(480, 20, 71, 16))
font = QtGui.QFont()
font.setFamily("Bahnschrift")
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(230, 10, 211, 31))
font = QtGui.QFont()
font.setFamily("Segoe Print")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label_4.setFrameShape(QtWidgets.QFrame.Box)
self.label_4.setLineWidth(3)
self.label_4.setScaledContents(False)
self.label_4.setIndent(24)
self.label_4.setObjectName("label_4")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.pushButton.clicked.connect(self.show_1)
self.pushButton_2.clicked.connect(self.show_2)
def show_1(self):
self.images.setPixmap(QtGui.QPixmap("D:/111.png"))
self.labels.setPixmap(QtGui.QPixmap("../yolov5-master/val_batch1_pred.jpg"))
def show_2(self):
self.images.setPixmap(QtGui.QPixmap("D:/222.png"))
self.labels.setPixmap(QtGui.QPixmap("../yolov5-master/val_batch2_pred.jpg"))
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton.setText(_translate("Dialog", "Button1"))
self.pushButton_2.setText(_translate("Dialog", "Button2"))
self.label_2.setText(_translate("Dialog", "32002165 张格菲"))
self.label_3.setText(_translate("Dialog", "2023.7.13"))
self.label_4.setText(_translate("Dialog", "F's experimental result"))
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
window = Ui_Dialog()
window.show()
sys.exit(app.exec_())
阅读全文