首页上一页 1 下一页尾页 1 条记录 1/1页
主窗体怎么调用子窗体啊
发表在Python图书答疑
2021-02-02 悬赏:2 学分
《PyQt5&Python游戏开发》第16章 学生成绩管理系统(PyQt5+MySQL+PyMySQL模块实现) 344页-345页
是否精华
是
否
版块置顶:
是
否
主窗体
# 为基础设置菜单中的QAction绑定triggered信号 self.menu.triggered[QtWidgets.QAction].connect(self.openSet) self.menu.triggered[QtWidgets.QAction].connect(self.openSett) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) datatime=QtCore.QDateTime.currentDateTime() # 获取当前日期时间 time=datatime.toString("yyyy-MM-dd HH:mm:ss") self.statusbar.showMessage("当前登录用户:" + " | 登录时间:" + time + " | 版权",0) #基础设置对应的槽函数 def openSet(self,m): import tianjia,yuandata # self.second=tianjia.Ui_MainWindow() if m.text()=='添加数据': self.m=tianjia.Ui_MainWindow() self.m.show() elif m.text()=='修改数据': self.m=yuandata.Ui_MainWindow() self.m.show() def openSett(self,s): import yuandata if s.text()=='加载数据': self.s=yuandata.Ui_MainWindow() self.s.show()
子窗体yuandata.py
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import * import sys sys.path.append("../") # 返回上层路径 class Ui_MainWindow(QMainWindow): # 构造方法 def __init__(self): super(Ui_MainWindow, self).__init__() self.setWindowFlags(QtCore.Qt.MSWindowsFixedSizeDialogHint) # 只显示最小化和关闭按钮 self.setupUi(self) # 初始化窗体设置 def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(751, 431) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.lineEdit = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit.setGeometry(QtCore.QRect(30, 50, 61, 21)) self.lineEdit.setObjectName("lineEdit") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(20, 10, 121, 41)) self.label.setObjectName("label") self.columnView = QtWidgets.QColumnView(self.centralwidget) self.columnView.setGeometry(QtCore.QRect(0, 0, 751, 431)) self.columnView.setObjectName("columnView") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(590, 30, 61, 41)) self.pushButton.setObjectName("pushButton") self.label_3 = QtWidgets.QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(120, 10, 121, 41)) self.label_3.setAlignment(QtCore.Qt.AlignCenter) self.label_3.setObjectName("label_3") self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_2.setGeometry(QtCore.QRect(150, 50, 61, 21)) self.lineEdit_2.setObjectName("lineEdit_2") self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(250, 10, 121, 41)) self.label_2.setObjectName("label_2") self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_3.setGeometry(QtCore.QRect(270, 50, 61, 21)) self.lineEdit_3.setObjectName("lineEdit_3") self.label_4 = QtWidgets.QLabel(self.centralwidget) self.label_4.setGeometry(QtCore.QRect(390, 10, 121, 41)) self.label_4.setObjectName("label_4")
def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.label.setText(_translate("MainWindow", "ul(长度的误差)")) self.pushButton.setText(_translate("MainWindow", "输出数据")) self.label_3.setText(_translate("MainWindow", "l(长度)")) self.label_2.setText(_translate("MainWindow", "i(选取数据的组数)")) self.label_4.setText(_translate("MainWindow", "t(样本的天数)")) self.label_5.setText(_translate("MainWindow", "Time")) self.label_6.setText(_translate("MainWindow", "C/C0")) self.label_7.setText(_translate("MainWindow", "RSD%"))