1. 涉及模块
- datetime
- os
- random
- sys
- PyQt5
2. 运行效果
支持功能:
- 添加信息
- 修改信息
- 删除信息
- 查询信息
- 文件存储数据,每次运行都会加载显示之前的信息
3.部分源码
代码语言:javascript复制# 创建字体对象,用来对要显示的文字进行设定
font = QtGui.QFont()
font.setFamily("黑体")
font.setPointSize(12)
# 姓名
label_name = QLabel(self)
label_name.setGeometry(40, 30, 54, 16)
label_name.setText("姓名:")
label_name.setFont(font)
self.line_edit_name = QLineEdit(self)
self.line_edit_name.setGeometry(90, 30, 141, 20)
# 性别
label_gender = QLabel(self)
label_gender.setGeometry(270, 30, 54, 16)
label_gender.setFont(font)
label_gender.setText("性别:")
self.line_edit_gender = QComboBox(self)
self.line_edit_gender.setGeometry(340, 30, 201, 20)
self.line_edit_gender.addItems(['男', '女'])
# 身份证
label_id = QLabel(self)
label_id.setGeometry(580, 30, 54, 16)
label_id.setFont(font)
label_id.setText("身份证:")
self.line_edit_id = QLineEdit(self)
self.line_edit_id.setGeometry(660, 30, 221, 20)
# 地址
label_addr = QLabel(self)
label_addr.setGeometry(40, 110, 54, 16)
label_addr.setFont(font)
label_addr.setText("地址:")
self.line_edit_addr = QLineEdit(self)
self.line_edit_addr.setGeometry(92, 110, 141, 20)
# 电话
label_phone = QLabel(self)
label_phone.setGeometry(270, 70, 54, 16)
label_phone.setFont(font)
label_phone.setText("电话:")
self.line_edit_phone = QLineEdit(self)
self.line_edit_phone.setGeometry(340, 70, 201, 20)