PyCharm GUI 病人病历管理系统: 用PyQt5创建可编辑保存的窗口
首先,我们可以使用PyQt5来创建一个新窗口并在其中显示病人病历信息。然后,我们可以添加一些文本框和按钮,以便用户可以在窗口中修改病人信息并保存。\n\n以下是一个示例代码:\n\npython\nimport sys\nfrom PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QTextEdit, QPushButton, QMessageBox\n\n\nclass PatientRecordWindow(QMainWindow):\n def __init__(self):\n super().__init__()\n\n self.setWindowTitle("病人病历")\n self.resize(400, 300)\n\n self.name_label = QLabel("姓名:", self)\n self.name_label.move(20, 20)\n self.name_input = QLineEdit(self)\n self.name_input.move(100, 20)\n\n self.age_label = QLabel("年龄:", self)\n self.age_label.move(20, 60)\n self.age_input = QLineEdit(self)\n self.age_input.move(100, 60)\n\n self.cause_label = QLabel("病因:", self)\n self.cause_label.move(20, 100)\n self.cause_input = QTextEdit(self)\n self.cause_input.move(100, 100)\n\n self.blood_type_label = QLabel("血型:", self)\n self.blood_type_label.move(20, 180)\n self.blood_type_input = QLineEdit(self)\n self.blood_type_input.move(100, 180)\n\n self.medical_history_label = QLabel("既往病史:", self)\n self.medical_history_label.move(20, 220)\n self.medical_history_input = QTextEdit(self)\n self.medical_history_input.move(100, 220)\n\n self.treatment_label = QLabel("治疗方案:", self)\n self.treatment_label.move(20, 280)\n self.treatment_input = QTextEdit(self)\n self.treatment_input.move(100, 280)\n\n self.save_button = QPushButton("保存", self)\n self.save_button.move(20, 340)\n self.save_button.clicked.connect(self.save_patient_record)\n\n def save_patient_record(self):\n name = self.name_input.text()\n age = self.age_input.text()\n cause = self.cause_input.toPlainText()\n blood_type = self.blood_type_input.text()\n medical_history = self.medical_history_input.toPlainText()\n treatment = self.treatment_input.toPlainText()\n\n # 这里可以将病人信息保存到文件或数据库中\n # 保存成功后,可以显示一个消息框来提示用户\n QMessageBox.information(self, "保存成功", "病人病历保存成功!")\n\n\nif __name__ == '__main__':\n app = QApplication(sys.argv)\n window = PatientRecordWindow()\n window.show()\n sys.exit(app.exec_())\n\n\n这段代码创建了一个名为PatientRecordWindow的新窗口,并在其中添加了姓名、年龄、病因、血型、既往病史、治疗方案等文本输入框和保存按钮。当用户点击保存按钮时,将获取输入框中的病人信息,并可以将其保存到文件或数据库中。\n\n你可以根据实际需求进一步调整窗口的布局和样式。
原文地址: https://www.cveoy.top/t/topic/pIN5 著作权归作者所有。请勿转载和采集!