from PyQt5 import QtCore, QtGui, QtWidgets from show1 import Ui_Form1 from show2 import Ui_Form2 from show3 import Ui_Form3 class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(400, 300) self.pushButton = QtWidgets.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(90, 60, 191, 51)) font = QtGui.QFont() font.setPointSize(9) self.pushButton.setFont(font) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(Form) self.pushButton_2.setGeometry(QtCore.QRect(90, 110, 191, 51)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_3 = QtWidgets.QPushButton(Form) self.pushButton_3.setGeometry(QtCore.QRect(90, 160, 191, 51)) self.pushButton_3.setObjectName("pushButton_3") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) self.pushButton.setText(_translate("Form", "无人机群显示")) self.pushButton_2.setText(_translate("Form", "无人机群数据分析展示")) self.pushButton_3.setText(_translate("Form", "无人机群飞行轨迹展示")) class MainWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() self.ui = Ui_Form() self.ui.setupUi(self) self.ui.pushButton.clicked.connect(self.showForm1) self.ui.pushButton_2.clicked.connect(self.showForm2) self.ui.pushButton_3.clicked.connect(self.showForm3) def showForm1(self): self.form1 = QtWidgets.QWidget() self.ui1 = Ui_Form1() self.ui1.setupUi(self.form1) self.form1.show() def showForm2(self): self.form2 = QtWidgets.QWidget() self.ui2 = Ui_Form2() self.ui2.setupUi(self.form2) self.form2.show() def showForm3(self): self.form3 = QtWidgets.QWidget() self.ui3 = Ui
时间: 2024-04-07 17:29:01 浏览: 190
python GUI库图形界面开发之PyQt5 UI主线程与耗时线程分离详细方法实例
_Form3()
self.ui3.setupUi(self.form3)
self.form3.show()
这段代码是一个基于PyQt5的GUI程序,使用了三个不同的UI文件(show1.py、show2.py、show3.py)来展示不同的功能界面。在UI类中,setupUi()方法用于设置UI的各个元素,retranslateUi()方法用于设置UI的翻译文本。在MainWindow类中,通过连接按钮的clicked信号,来分别展示不同的UI界面。showForm1()、showForm2()、showForm3()方法分别用于展示不同的UI界面,其中每个界面都有对应的UI类来设置UI元素。
阅读全文