Python人员信息管理系统源程序

发布时间:2024-03-17 17:01

Python人员信息管理系统源程序,本项目代码量在500行左右,代码不难,展示一个功能完善的入门级别的PyQt项目,是练手提升能力的非常好的项目。程序运行截图:\"Python人员信息管理系统源程序_第1张图片\"
主要程序代码

    def init_ui(self):
        \"\"\"设置UI界面\"\"\"
        self.setWindowTitle(\"人员管理系统_Python代码大全\")
        self.setFixedSize(1220, 771)

        # 创建字体对象,用来对要显示的文字进行设定
        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)

        # 部门
        label_department = QLabel(self)
        label_department.setGeometry(590, 70, 54, 16)
        label_department.setFont(font)
        label_department.setText(\"部门:\")
        self.line_edit_department = QLineEdit(self)
        self.line_edit_department.setGeometry(660, 70, 221, 20)

        # 出生日期
        label_birthdate = QLabel(self)
        label_birthdate.setGeometry(580, 110, 81, 16)
        label_birthdate.setFont(font)
        label_birthdate.setText(\"出生日期:\")
        self.line_edit_birthday = QDateTimeEdit(self)
        self.line_edit_birthday.setGeometry(670, 110, 211, 20)
        self.line_edit_birthday.setCalendarPopup(True)
        self.line_edit_birthday.setDisplayFormat(\"yyyy-MM-dd\")

        # 专业
        label_skill = QLabel(self)
        label_skill.setGeometry(40, 70, 51, 16)
        label_skill.setFont(font)
        label_skill.setText(\"专业:\")
        self.line_edit_skill = QLineEdit(self)
        self.line_edit_skill.setGeometry(90, 70, 141, 20)

        # 职务
        label_post = QLabel(self)
        label_post.setGeometry(270, 110, 51, 16)
        label_post.setFont(font)
        label_post.setText(\"职务:\")
        self.line_edit_post = QLineEdit(self)
        self.line_edit_post.setGeometry(340, 110, 201, 20)

        # 备注
        label_note = QLabel(self)
        label_note.setGeometry(40, 150, 51, 16)
        label_note.setFont(font)
        label_note.setText(\"备注:\")
        self.text_edit_note = QTextEdit(self)
        self.text_edit_note.setGeometry(90, 150, 381, 71)

        # btn:录入信息
        btn_add_info = QPushButton(self)
        btn_add_info.setGeometry(580, 190, 75, 23)
        btn_add_info.setText(\"录入信息\")
        # 事件绑定
        btn_add_info.clicked.connect(self.add_new_student_info)

        # btn:修改信息
        self.btn_change = QPushButton(\"修改信息\", self)
        self.btn_change.setGeometry(700, 190, 75, 23)
        self.btn_change.setVisible(False)
        # 事件绑定
        self.btn_change.clicked.connect(self.save_change_info)

        # 人员信息表
        self.table_infos = QTableWidget(self)
        self.table_infos.setGeometry(10, 350, 1200, 411)
        self.table_infos.setColumnCount(11)
        self.table_infos.setHorizontalHeaderLabels([
            \'编号\', \'姓名\', \'性别\', \'身份证\', \'专业\', \'电话\', \'部门\', \'地址\', \'职务\', \'出生日期\', \'备注\'
        ])
        # 禁用双击编辑单元格
        self.table_infos.setEditTriggers(QAbstractItemView.NoEditTriggers)
        # 改为选择一行
        self.table_infos.setSelectionBehavior(QAbstractItemView.SelectRows)
        # 添加右击菜单
        self.table_infos.setContextMenuPolicy(Qt.CustomContextMenu)
        self.table_infos.customContextMenuRequested.connect(self.generate_menu)

        # 隐藏的文本框,用来存储编号
        self.person_no = QLineEdit(self)
        self.person_no.setGeometry(90, 220, 141, 20)
        self.person_no.setVisible(False)

        # btn:查看全部
        self.btn_find_all = QPushButton(self)
        self.btn_find_all.setGeometry(74, 290, 81, 23)
        self.btn_find_all.setText(\"查看全部\")
        # 事件绑定
        self.btn_find_all.clicked.connect(self.get_all_infos)

        # 按类型查找
        self.label_find_type = QLabel(self)
        self.label_find_type.setGeometry(330, 295, 91, 16)
        self.label_find_type.setFont(font)
        self.label_find_type.setText(\"按类型查找\")

        # 下拉菜单,查找类型
        self.select_btn = QComboBox(self)
        self.select_btn.setGeometry(420, 290, 111, 22)
        find_type = [\"姓名\", \"性别\", \"身份证\", \"专业\", \"部门\", \"编号\", \"出生日期范围\"]
        for i, type_temp in enumerate(find_type):
            self.select_btn.addItem(\"\")
            self.select_btn.setItemText(i, type_temp)
        # 事件绑定
        self.select_btn.currentIndexChanged.connect(self.change_search_type)

        # 查找输入框
        self.line_edit_find = QLineEdit(self)
        self.line_edit_find.setGeometry(550, 290, 161, 20)

        # 查找日期范围(默认不显示,只有当选择查询日期范围时才显示)
        self.line_edit_star_time = QDateTimeEdit(self)
        self.line_edit_star_time.setGeometry(550, 290, 100, 20)
        self.line_edit_star_time.setCalendarPopup(True)
        self.line_edit_star_time.setDisplayFormat(\"yyyy-MM-dd\")
        self.line_edit_star_time.setVisible(False)
        self.line_edit_end_time = QDateTimeEdit(self)
        self.line_edit_end_time.setGeometry(655, 290, 100, 20)
        self.line_edit_end_time.setCalendarPopup(True)
        self.line_edit_end_time.setDisplayFormat(\"yyyy-MM-dd\")
        self.line_edit_end_time.setVisible(False)

        # btn:查找
        self.btn_find = QPushButton(self)
        self.btn_find.setGeometry(780, 290, 75, 23)
        self.btn_find.setText(\"查找\")
        # 事件绑定
        self.btn_find.clicked.connect(self.search_info_from_files)

完整程序代码下载地址:Python人员信息管理系统

更多Python源代码,请关注:Python代码大全。
\"Python人员信息管理系统源程序_第2张图片\"

ItVuer - 免责声明 - 关于我们 - 联系我们

本网站信息来源于互联网,如有侵权请联系:561261067@qq.com

桂ICP备16001015号