这是简易版本的实体管理,目前只实现了在各个框里设置信息,按按钮显示信息
接下来还要规定输入的类型,如果类型不对,则会弹出对话框,只有类型都正确按按钮才能显示信息
之后把按按钮显示的信息录入到表格里,实现表格增删改查,排序什么的
这个1.0版本有两个文件:一个是由qt designer生成的页面文件,另一个是继承页面类的逻辑文件
`
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(975, 499)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(30, 20, 51, 41))
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(90, 30, 151, 31))
self.lineEdit.setObjectName("lineEdit")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(320, 30, 72, 15))
self.label_2.setObjectName("label_2")
self.comboBox = QtWidgets.QComboBox(self.centralwidget)
self.comboBox.setGeometry(QtCore.QRect(380, 30, 151, 22))
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(620, 30, 72, 15))
self.label_3.setObjectName("label_3")
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(700, 30, 251, 21))
self.lineEdit_2.setObjectName("lineEdit_2")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(30, 100, 72, 15))
self.label_4.setObjectName("label_4")
self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_3.setGeometry(QtCore.QRect(90, 100, 151, 31))
self.lineEdit_3.setObjectName("lineEdit_3")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(320, 100, 72, 15))
self.label_5.setObjectName("label_5")
self.spinBox = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox.setGeometry(QtCore.QRect(380, 91, 131, 41))
self.spinBox.setObjectName("spinBox")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(620, 100, 72, 15))
self.label_6.setObjectName("label_6")
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setGeometry(QtCore.QRect(700, 90, 231, 81))
self.textEdit.setObjectName("textEdit")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(380, 210, 131, 91))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 975, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.pushButton.clicked.connect(MainWindow.enter) # type: ignore
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "姓名"))
self.label_2.setText(_translate("MainWindow", "性别"))
self.comboBox.setItemText(0, _translate("MainWindow", "男"))
self.comboBox.setItemText(1, _translate("MainWindow", "女"))
self.label_3.setText(_translate("MainWindow", "身份证号"))
self.label_4.setText(_translate("MainWindow", "专业"))
self.label_5.setText(_translate("MainWindow", "年龄"))
self.label_6.setText(_translate("MainWindow", "备注"))
self.pushButton.setText(_translate("MainWindow", "录入信息"))
逻辑(主文件):
import sys
from PyQt5.QtWidgets import *
from uach import *
class My(QMainWindow,Ui_MainWindow):
def init(self,parent=None):
super(My, self).init(parent)
self.setupUi(self)
def enter(self):
a1 = self.lineEdit.text()
a2 = self.lineEdit_2.text()
a3 = self.lineEdit_3.text()
x = self.comboBox.currentText()
z = self.textEdit.toPlainText()
QMessageBox.about(self,'###','name:'+a1+'id:'+a2+'sex:'+x+'job:'+a3)
QMessageBox.about(self,'@@',z)
if name == 'main':
app = QApplication(sys.argv)
m = My()
m.show()
sys.exit(app.exec())
`