def updateStudentFunction(self, SID: str): stu_info = database.get_student_info(SID) if stu_info is None: return self.updateStudentDialog = student_information.StudentInfo(stu_info) self.updateStudentDialog.after_close.connect(self.updateStudent) self.updateStudentDialog.show()
def __init__(self, stu_mes): super().__init__() self.stu_mes = database.get_student_info(stu_mes['SID']) # 学号输入框 account = QLabel() account.setText('学号') self.accountInput = QLineEdit() self.accountInput.setFixedSize(400, 40) self.accountInput.setText(self.stu_mes['SID']) self.accountInput.setTextMargins(5, 5, 5, 5) self.accountInput.setEnabled(False) accountLayout = QHBoxLayout() accountLayout.addStretch() accountLayout.addWidget(account) accountLayout.addWidget(self.accountInput) # 姓名输入框 name = QLabel() name.setText('姓名') self.nameInput = QLineEdit() self.nameInput.setFixedSize(400, 40) self.nameInput.setText(self.stu_mes['SNAME']) self.nameInput.setTextMargins(5, 5, 5, 5) self.nameInput.setEnabled(False) nameLayout = QHBoxLayout() nameLayout.addStretch() nameLayout.addWidget(name) nameLayout.addWidget(self.nameInput) # 密码 password = QLabel() password.setText('密码') self.passwordInput = QLineEdit() self.passwordInput.setFixedSize(400, 40) self.passwordInput.setText('******') self.passwordInput.setEchoMode(QLineEdit.Password) self.passwordInput.setTextMargins(5, 5, 5, 5) self.passwordInput.setEnabled(False) passwordLayout = QHBoxLayout() passwordLayout.addStretch() passwordLayout.addWidget(password) passwordLayout.addWidget(self.passwordInput) # 重复密码 repPassword = QLabel() repPassword.setText('重复密码') self.repPasswordInput = QLineEdit() self.repPasswordInput.setFixedSize(400, 40) self.repPasswordInput.setText('******') self.repPasswordInput.setEchoMode(QLineEdit.Password) self.repPasswordInput.setTextMargins(5, 5, 5, 5) self.repPasswordInput.setEnabled(False) repPasswordLayout = QHBoxLayout() repPasswordLayout.addStretch() repPasswordLayout.addWidget(repPassword) repPasswordLayout.addWidget(self.repPasswordInput) # 最大借书数 maxNum = QLabel() maxNum.setText('最大借书数') self.maxNumInput = QLineEdit() self.maxNumInput.setFixedSize(400, 40) self.maxNumInput.setText(str(self.stu_mes['MAX'])) self.maxNumInput.setTextMargins(5, 5, 5, 5) self.maxNumInput.setEnabled(False) maxNumLayout = QHBoxLayout() maxNumLayout.addStretch() maxNumLayout.addWidget(maxNum) maxNumLayout.addWidget(self.maxNumInput) # 学院 dept = QLabel() dept.setText('学院') self.deptInput = QLineEdit() self.deptInput.setFixedSize(400, 40) self.deptInput.setText(self.stu_mes['DEPARTMENT']) self.deptInput.setTextMargins(5, 5, 5, 5) self.deptInput.setEnabled(False) deptLayout = QHBoxLayout() deptLayout.addStretch() deptLayout.addWidget(dept) deptLayout.addWidget(self.deptInput) # 专业 major = QLabel() major.setText('专业') self.majorInput = QLineEdit() self.majorInput.setFixedSize(400, 40) self.majorInput.setText(self.stu_mes['MAJOR']) self.majorInput.setTextMargins(5, 5, 5, 5) self.majorInput.setEnabled(False) majorLayout = QHBoxLayout() majorLayout.addStretch() majorLayout.addWidget(major) majorLayout.addWidget(self.majorInput) # 保存 self.save = QToolButton() self.save.setText('保存') self.save.setFixedSize(100, 40) self.save.setEnabled(False) self.save.clicked.connect(self.saveFunction) # 修改 self.modify = QToolButton() self.modify.setText('修改') self.modify.setFixedSize(100, 40) self.modify.clicked.connect(self.modifyFunction) btnLayout = QHBoxLayout() btnLayout.addSpacing(130) btnLayout.addWidget(self.modify) btnLayout.addWidget(self.save) btnLayout.addStretch() self.bodyLayout = QVBoxLayout() self.bodyLayout.addLayout(accountLayout) self.bodyLayout.addLayout(nameLayout) self.bodyLayout.addLayout(passwordLayout) self.bodyLayout.addLayout(repPasswordLayout) self.bodyLayout.addLayout(deptLayout) self.bodyLayout.addLayout(majorLayout) self.bodyLayout.addLayout(maxNumLayout) self.bodyLayout.addLayout(btnLayout) self.bodyLayout.addStretch() self.setLayout(self.bodyLayout) self.initUI()