Python實(shí)現(xiàn)功能完整的個(gè)人員管理程序
一簡(jiǎn)介
本軟件作用于人員管理,
1創(chuàng)建一個(gè)崗位管理界面,點(diǎn)擊崗位管理之后,設(shè)置好崗位名稱(chēng),拖動(dòng)鼠標(biāo)畫(huà)框,完成崗位創(chuàng)建,之后里面可以放置人員。
可以將之前建立的崗位刪除,同時(shí)里面的人員也會(huì)刪除。
2新增人員,包括(身份信息用不同顏色表示,崗位信息代表處于何種崗位)
3人員可以拖動(dòng)到任意崗位,崗位也可以拖動(dòng)到任意位置
4保存和讀取功能
如圖所示
管理崗位
新增人員
人員狀態(tài)管理
二 代碼部分
分兩次寫(xiě)的,借鑒很多,語(yǔ)法較亂,基本都有標(biāo)注
pydesigner生成的四個(gè)界面內(nèi),然后重寫(xiě)按鍵類(lèi)使其可以拖動(dòng)
1.主代碼boy_main.py
# -*- coding:utf-8 -*- import ast # 文本轉(zhuǎn)字典 import sys from PyQt5.QtCore import Qt, QRect from PyQt5.QtGui import QPainter, QPen from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget # 布局的框體 from boy_ui_main import Ui_MainWindow # 導(dǎo)入第一個(gè)py,主窗口 from boy_ui_new import Ui_newboy # 導(dǎo)入第二個(gè)py,新增成員窗口 from manager_ui_gangwei import Ui_widget # 導(dǎo)入第三個(gè)py,崗位管理窗口 import button # 導(dǎo)入的第四個(gè)py,按鍵重寫(xiě),第四個(gè)窗口導(dǎo)入了這里 save_data_anjian = dict() # 需要保存的按鍵字典 save_data_layout = dict() # 需要保存的框體字典 # 主窗口 class MainWindow(QMainWindow, Ui_MainWindow): # 多重繼承QMainWindow和Ui_MainWindow def __init__(self): super(MainWindow, self).__init__() # 先調(diào)用父類(lèi)QMainWindow的初始化方法 self.setupUi(self) # 再調(diào)用setupUi方法 self.newboyshow = newwindow_anjian() # 實(shí)例化新建成員窗口 self.newgangweishow = newwindow_gangwei() # 實(shí)例化管理崗位窗口 self.add_boy.triggered.connect(self.newshow) # 為增加人員按鈕添加打開(kāi)新窗口的動(dòng)作 self.saveaction.triggered.connect(self.savenow) # 為保存增加保存savedata的動(dòng)作 self.openaction.triggered.connect(self.opennow) # 為打開(kāi)增加打開(kāi)savedata的動(dòng)作 self.add_gangwei_huakuang.triggered.connect(self.manager_gangwei) # 為增加崗位增加管理崗位功能,可以畫(huà)了 self.setAcceptDrops(True) # 拖動(dòng)按鍵用——人員 self.sig_huakuang = 0 # 畫(huà)框用,=0時(shí)不讓畫(huà)框 self.x0 = 0 # 畫(huà)框用 self.y0 = 0 # 畫(huà)框用 self.x1 = 0 # 畫(huà)框用 self.y1 = 0 # 畫(huà)框用 self.flag = False # # 畫(huà)框用,鼠標(biāo)未按下 self.move = False # # 畫(huà)框用,存在移動(dòng) self.gangwei = 0 # 初始崗位設(shè)置 self.x_move = None#拖動(dòng)崗位框體后的坐標(biāo) self.y_move = None#拖動(dòng)崗位框體后的坐標(biāo) # 管理崗位頁(yè)面,在新崗位頁(yè)面設(shè)置完了崗位,點(diǎn)了確定,才能畫(huà)框 def manager_gangwei(self): self.newgangweishow.show() # 畫(huà)框用第一步---單擊鼠標(biāo)觸發(fā)事件,初始左上角的點(diǎn) def mousePressEvent(self, event): # barHeight = self.bar.height() self.x0 = event.pos().x() self.y0 = event.pos().y() self.flag = True # 畫(huà)框用第二步--鼠標(biāo)移動(dòng)事件 def mouseMoveEvent(self, event): # barHeight = self.bar.height() self.move = True if self.flag: self.x1 = event.pos().x() self.y1 = event.pos().y() self.update() # 畫(huà)框用第三步,只要拖動(dòng)就會(huì)一直繪制事件 def paintEvent(self, event): super().paintEvent(event) painter = QPainter(self) # 拖動(dòng)時(shí)候的臨時(shí)框 painter.setPen(QPen(Qt.green, 2, Qt.SolidLine))#畫(huà)筆設(shè)置 # 打開(kāi)之后,再畫(huà)或者最大化以后才能出現(xiàn),不知道為啥,對(duì)刷新不太了解 for rec in save_data_layout.values():#遍歷所有的框體,一直畫(huà) painter.drawRect(QRect(rec[0], rec[1], rec[2], rec[3])) if self.flag and self.move and self.sig_huakuang == 1: # 只有當(dāng)鼠標(biāo)按下并且移動(dòng)狀態(tài) rect = QRect(self.x0, self.y0, abs(self.x1 - self.x0), abs(self.y1 - self.y0)) painter.setPen(QPen(Qt.red, 2, Qt.SolidLine)) painter.drawRect(rect) # 畫(huà)框用第四步--鼠標(biāo)釋放事件,清零,并且不再繪制,self.sig_huakuang=0 def mouseReleaseEvent(self, event): self.flag = False # 不再按下 self.move = False # 不再移動(dòng) self.x_move = event.pos().x() # 拖動(dòng)崗位類(lèi)的最終位置 self.y_move = event.pos().y() # 拖動(dòng)崗位類(lèi)的最終位置 # 釋放鼠標(biāo)時(shí)儲(chǔ)存 if self.x1 and self.y1 and self.sig_huakuang == 1: # 不移動(dòng)按了沒(méi)用,也就是有寬度和高度時(shí) print("鼠標(biāo)放下") gangwei = self.gangwei # 框體的臨時(shí)名稱(chēng) rec = self.x0, self.y0, abs(self.x1 - self.x0), abs(self.y1 - self.y0) # 位置和大小 save_data_layout[gangwei] = rec # 保存這個(gè)框體的數(shù)據(jù) # 同時(shí)建立一個(gè)布局和一個(gè)按鈕顯示布局信息 self.draw_rect(gangwei, rec) # 執(zhí)行創(chuàng)建崗位命令 self.sig_huakuang = 0 # 使其不能再畫(huà) # print("崗位狀態(tài)", button.Y.mouseMoveEvent(event),self.x1, self.y1,self.sig_huakuang) # 如果有崗位按鍵,并且現(xiàn)在不讓畫(huà)框,并且按了左鍵拖動(dòng)了:那么移動(dòng)崗位和布局控件,修改存儲(chǔ)的數(shù)據(jù),button.Y=目前的崗位框 if button.Y and self.sig_huakuang == 0 and button.U: ganwgei = button.Y.text() # 從按鍵名字提取崗位信息 self.__dict__["pushButton" + ganwgei].move(self.x_move, self.y_move - 55) # 55,修改個(gè)位置 self.__dict__["gridLayoutWidget" + ganwgei].move(self.x_move, self.y_move - 30) # 更改數(shù)據(jù)信息 # print(type(save_data_layout[ganwgei])) <class 'tuple'> 單個(gè)值沒(méi)法修改 xx = save_data_layout[ganwgei][2] # 只能更改字典值 yy = save_data_layout[ganwgei][3] # 只能更改字典值 save_data_layout[ganwgei] = (self.x_move, self.y_move, xx, yy) # 保存新的崗位信息 button.U = 0 # 設(shè)置完了就不能動(dòng)了,除非再點(diǎn)按鈕 self.x0, self.y0, self.x1, self.y1 = (0, 0, 0, 0) # 鼠標(biāo)重新設(shè)置 # 畫(huà)框體、按鍵、和布局.打開(kāi)文件和創(chuàng)建時(shí)候用。同時(shí)增加人員崗位可選項(xiàng) def draw_rect(self, gangwei, rec): # print(rec[0], rec[1], rec[2], rec[3])#左上點(diǎn)和 寬。高self.centralwidget self.__dict__["gridLayoutWidget" + gangwei] = QWidget(self.centralwidget) # 布局要放到個(gè)容器里 self.__dict__["gridLayoutWidget" + gangwei].setGeometry(QRect(rec[0], rec[1], rec[2], rec[3])) # 容器大小 # self.__dict__["gridLayoutWidget" + gangwei].setObjectName(gangwei)#控件名字 self.__dict__["layout" + gangwei] = QVBoxLayout() # 做個(gè)垂直布局 self.__dict__["layout" + gangwei].setContentsMargins(0, 0, 0, 0) # 上下左右不留縫隙 self.__dict__["gridLayoutWidget" + gangwei].setLayout(self.__dict__["layout" + gangwei]) # 容器使用這個(gè)垂直布局 self.__dict__["gridLayoutWidget" + gangwei].show() # 容器要顯示,少了這個(gè)麻煩了 # 按鈕顯示 同寬,往上50像素,高30像素 rectanjian = QRect(rec[0], rec[1] - 55, rec[2], 30) self.__dict__["pushButton" + gangwei] = button.Buttongangwei(self.centralwidget, gangwei, rectanjian) self.__dict__["pushButton" + gangwei].show()#按鍵顯示 # 增加了崗位,人員可以選 self.newboyshow.comboBox.addItems([gangwei]) # 增加了可以刪除的崗位 self.newgangweishow.comboBox.addItems([gangwei]) def newshow(self): # 打開(kāi)新窗口的動(dòng)作 self.newboyshow.show() def savenow(self): # 保存的動(dòng)作 file1 = open("boysavedata_anjian.txt", "w") # 保存按鍵 file1.write(str(save_data_anjian)) print("寫(xiě)入成功按鍵", save_data_anjian) file1.close() file = open("boysavedata_layout.txt", "w") # 保存崗位框 file.write(str(save_data_layout)) print("寫(xiě)入成功崗位", save_data_layout) file.close() def opennow(self): # 打開(kāi)之前保存的數(shù)據(jù) global save_data_anjian, save_data_layout # 打開(kāi)按鍵信息 with open("boysavedata_anjian.txt", "r") as file: save_data_anjian = ast.literal_eval(file.read()) # 將讀取的字符串轉(zhuǎn)為字典 # print("按鍵信息", save_data_anjian) # 打開(kāi)崗位信息 with open("boysavedata_layout.txt", "r") as file1: # print(file1.read())多加這一句話,捯飭半天,read以后就沒(méi)了,再讀就是空的,所以底下會(huì)報(bào)錯(cuò) save_data_layout = ast.literal_eval(file1.read()) # 將讀取的字符串轉(zhuǎn)為字典 #print("崗位信息", save_data_layout) for gangwei, rec in save_data_layout.items(): # 提取名字和方塊 self.draw_rect(gangwei, rec) # 執(zhí)行創(chuàng)建崗位命令 for name, shuxing in save_data_anjian.items(): # 提取名字和屬性,屬性0為身份,屬性1為崗位 self.setpushbutton(name, shuxing) # 按鍵加入到崗位 self.showMaximized() # 窗口最大化后才顯示,不知道為啥 def setpushbutton(self, name, shuxing): # 通過(guò)名字和屬性建立按鍵并歸位 # 點(diǎn)擊確定后新增按鍵,實(shí)例化按鍵,shuxing[0]=身份,shuxing[1]=崗位 buttonnew = button.Button(name, ui, shuxing[0], shuxing[1]) # 點(diǎn)擊確定后新增按鍵,實(shí)例化按鍵,shuxing[0]=身份 buttonnew.colorful() # 按鍵根據(jù)身份增加顏色,在button里新增的函數(shù) buttonnew.move(100, 100)#如果最開(kāi)始沒(méi)崗位,就移動(dòng)到這個(gè)位置,可以沒(méi)有 buttonnew.show() # 按鍵顯示出來(lái) for gangwei in save_data_layout.keys(): if gangwei == shuxing[1]: self.__dict__["layout" + gangwei].addWidget(buttonnew) # 放置到新崗位 def dragEnterEvent(self, e): # 拖動(dòng)用 e.accept() # 定義了按鈕按下后和釋放后的行為, # 獲得鼠標(biāo)移動(dòng)的位置,然后把人員按鍵放到這個(gè)地方,修改自身崗位并且保存下來(lái) def dropEvent(self, e): position = e.pos() for gangwei, rec in save_data_layout.items(): if position in QRect(rec[0], rec[1], rec[2], rec[3]): button.x.gangwei = gangwei # 設(shè)置新崗位 save_data_anjian[button.x.name][1] = button.x.gangwei # 保存新崗位 #print(f"新崗位為{save_data_anjian[button.x.name]}", gangwei) self.__dict__["layout" + gangwei].addWidget(button.x) # button.X為拖動(dòng)按鍵的本身,放置到新崗位 # 指定放下的動(dòng)作類(lèi)型為moveAction e.setDropAction(Qt.MoveAction) e.accept() # 增加人員的新窗口 class newwindow_anjian(QWidget, Ui_newboy): def __init__(self): super(newwindow_anjian, self).__init__() self.setupUi(self) def addok(self): # 增加完人員,選擇確定時(shí)候 # global name,shenfen name = self.lineEdit.text() shenfen = self.comboBox_2.currentText() zhiwu = self.comboBox.currentText() shuxing = [shenfen, zhiwu] save_data_anjian[name] = shuxing ui.setpushbutton(name, shuxing) # 輸入名字和身份,建立按鍵 # 管理崗位的新窗口 class newwindow_gangwei(QWidget, Ui_widget): def __init__(self): super(newwindow_gangwei, self).__init__() self.setupUi(self) def del_gangwei_ok(self):#刪除崗位的按鍵動(dòng)作 tex = self.comboBox.currentText() # 要?jiǎng)h除的崗位 # 讓這個(gè)三個(gè)不顯示 ui.__dict__["gridLayoutWidget" + tex].deleteLater() ui.__dict__["layout" + tex].deleteLater() ui.__dict__["pushButton" + tex].deleteLater() # 讓這三個(gè)不存在 del ui.__dict__["gridLayoutWidget" + tex] del ui.__dict__["layout" + tex] del ui.__dict__["pushButton" + tex] del save_data_layout[tex] self.close() # 關(guān)閉本身窗口 def add_gangwei_ok(self):#增加崗位的按鍵 ui.sig_huakuang = 1#增加崗位后才能畫(huà)崗位 ui.gangwei = self.lineEdit.text()#增加的崗位的名字 self.close() # 關(guān)閉 if __name__ == '__main__': app = QApplication(sys.argv) ui = MainWindow() ui.show() sys.exit(app.exec_())
2.button.py
import sys from PyQt5.QtCore import Qt, QMimeData, QRect from PyQt5.QtGui import QDrag, QIcon from PyQt5.QtWidgets import QPushButton, QWidget, QApplication from rightclickfrom import Ui_Rrightclickform#導(dǎo)入人員按鍵右鍵的窗口 x=0#按鍵自己本身 Y=0#崗位按鍵本身 U=0#控制崗位類(lèi)拖動(dòng) #人員類(lèi)按鍵 # 從 QPushButton 繼承一個(gè) Button 類(lèi) class Button(QPushButton): def __init__(self, name, parent,shenfen=0,gangwei=0): super().__init__(name, parent) self.name=name self.shenfen=shenfen self.gangwei=gangwei self.newform = rightclict_window()#右鍵的畫(huà)面 def colorful(self):#增加按鍵顏色 if self.shenfen=="機(jī)器人": self.setStyleSheet('''QPushButton{background:#76becc;border-radius:5px;}QPushButton:hover{background:yellow;}''') elif self.shenfen=="軍火商": self.setStyleSheet('''QPushButton{background:"#f7acbc";border-radius:5px;}QPushButton:hover{background:yellow;}''') elif self.shenfen == "特種兵": self.setStyleSheet('''QPushButton{background:"#f58220";border-radius:5px;}QPushButton:hover{background:yellow;}''') elif self.shenfen == "電動(dòng)車(chē)": self.setStyleSheet('''QPushButton{background:"#4e72b8";border-radius:5px;}QPushButton:hover{background:yellow;}''') else:pass # 重構(gòu)mouseMoveEvent方法 def mouseMoveEvent(self, e): global x x=self#取得按鍵本身 # 劫持按鈕的左鍵事件,右鍵的操作還是默認(rèn)行為 if e.buttons() != Qt.LeftButton: return # 創(chuàng)建一個(gè) QDrag 對(duì)象,用來(lái)傳輸MIME-based數(shù)據(jù) mimeData = QMimeData()#這幾句沒(méi)看懂,照抄的 drag = QDrag(self) drag.setMimeData(mimeData) drag.setHotSpot(e.pos() - self.rect().topLeft()) # 拖放事件開(kāi)始時(shí),用到的處理函數(shù)式 start() dropAction = drag.exec_(Qt.MoveAction) # 重構(gòu)mousePressEvent方法 # 右鍵點(diǎn)擊按鈕,彈出新窗口 def mousePressEvent(self, e): global x x=self # 注意,我們?cè)诟讣?jí)上也調(diào)用 了 mousePressEvent() 方法, # 不然的話,我們是看不到按鈕按下的效果 的 super().mousePressEvent(e) if e.button() == Qt.RightButton: self.newform.show()#右鍵彈出畫(huà)面 #self.deleteLater()#刪除按鍵 #人員類(lèi)按鍵打開(kāi)的窗口 class rightclict_window(QWidget,Ui_Rrightclickform): def __init__(self): super(rightclict_window, self).__init__() self.setupUi(self) def delputbutton(self):#刪除按鍵 global x print("del") x.deleteLater()#刪除本按鍵 def jieok(self): jiezou_sha=self.comboBoxjiezou.currentText()#借走了啥 sha_biaojia=self.comboBoxbiaoji.currentText()#做了哪些標(biāo)記 print(jiezou_sha,sha_biaojia) if jiezou_sha=="無(wú)":#如果沒(méi)接,不多顯示 x.setText(x.name)#清除標(biāo)記 else:x.setText(x.name+jiezou_sha)#否則顯示借閱 if sha_biaojia=="無(wú)":#如果沒(méi)標(biāo)記,清楚標(biāo)記 x.setIcon(QIcon()) elif sha_biaojia=="休假": x.setIcon(QIcon("櫻桃.png")) elif sha_biaojia=="出差": x.setIcon(QApplication.style().standardIcon(13))#增加系統(tǒng)自帶的ICON類(lèi)圖標(biāo) else:pass #崗位類(lèi)按鍵 class Buttongangwei(QPushButton): def __init__(self,parent, name,rect=QRect(0,0,0,0),): super().__init__(parent) # 先調(diào)用父類(lèi)Qpushbytton的初始化方法 #self.rect=rect self.name=name self.setGeometry(rect) self.setObjectName(f"{self.name}") self.setText(f"{self.name}") #self.new_window_ganwgei = Ui_rightclick_gangwei_window() # 實(shí)例化一個(gè)右鍵的畫(huà)面 def mouseMoveEvent(self, e): global Y,U Y=self#取得按鍵本身 # 劫持按鈕的左鍵事件,右鍵的操作還是默認(rèn)行為 if e.buttons() != Qt.LeftButton: #如果鼠標(biāo)點(diǎn)擊事件發(fā)生了,不是左鍵就結(jié)束,是左鍵就繼續(xù)往下 return print("左鍵拖動(dòng)事件事件") U=1#左鍵拖動(dòng)了 # 重構(gòu)mousePressEvent方法 # 右鍵點(diǎn)擊按鈕,彈出畫(huà)面——————未開(kāi)發(fā) def mousePressEvent(self, e): global Y Y=self # 注意,我們?cè)诟讣?jí)上也調(diào)用 了 mousePressEvent() 方法, # 不然的話,我們是看不到按鈕按下的效果 的 if e.button() == Qt.RightButton: pass class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setAcceptDrops(True) self.button = Buttongangwei(self,"mmap",QRect(100,100,100,100)) self.button.move(100,100) self.button.show() self.button4 = Button('Button1', self) self.button4.move(159, 65) #self.button.move(100, 65) self.setWindowTitle('Click or Move') self.setGeometry(300, 300, 280, 150) def dragEnterEvent(self, e): e.accept() def delpushbotton(self): pass # 定義了按鈕按下后和釋放后的行為, # 獲得鼠標(biāo)移動(dòng)的位置,然后把按鈕放到這個(gè)地方 def dropEvent(self, e): position = e.pos() print(self) self.button.move(position) # 指定放下的動(dòng)作類(lèi)型為moveAction e.setDropAction(Qt.MoveAction) e.accept() if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() ex.show() app.exec_()
3.生成的主頁(yè)面ui的代碼,自動(dòng)生成的打包用,不用看。boy_ui_main.py
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'boy_ui_main.ui' # # Created by: PyQt5 UI code generator 5.15.6 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(797, 566) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 797, 23)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.toolBar = QtWidgets.QToolBar(MainWindow) self.toolBar.setObjectName("toolBar") MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) self.add_boy = QtWidgets.QAction(MainWindow) self.add_boy.setObjectName("add_boy") self.openaction = QtWidgets.QAction(MainWindow) self.openaction.setObjectName("openaction") self.saveaction = QtWidgets.QAction(MainWindow) self.saveaction.setObjectName("saveaction") self.add_gangwei_huakuang = QtWidgets.QAction(MainWindow) self.add_gangwei_huakuang.setObjectName("add_gangwei_huakuang") self.toolBar.addAction(self.openaction) self.toolBar.addAction(self.saveaction) self.toolBar.addAction(self.add_boy) self.toolBar.addAction(self.add_gangwei_huakuang) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "崗位管理1.0—QQ294794719")) self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar")) self.add_boy.setText(_translate("MainWindow", "增加人員")) self.add_boy.setToolTip(_translate("MainWindow", "增加成員")) self.openaction.setText(_translate("MainWindow", "打開(kāi)")) self.openaction.setToolTip(_translate("MainWindow", "打開(kāi)保存的文件")) self.saveaction.setText(_translate("MainWindow", "保存")) self.saveaction.setToolTip(_translate("MainWindow", "保存數(shù)據(jù)")) self.add_gangwei_huakuang.setText(_translate("MainWindow", "崗位管理")) self.add_gangwei_huakuang.setToolTip(_translate("MainWindow", "崗位管理"))
4.生成增加成員的ui的代碼。boy_ui_new.py
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'boy_ui_new.ui' # # Created by: PyQt5 UI code generator 5.15.6 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets class Ui_newboy(object): def setupUi(self, newboy): newboy.setObjectName("newboy") newboy.resize(371, 137) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(newboy.sizePolicy().hasHeightForWidth()) newboy.setSizePolicy(sizePolicy) self.layoutWidget = QtWidgets.QWidget(newboy) self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 351, 126)) self.layoutWidget.setObjectName("layoutWidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label = QtWidgets.QLabel(self.layoutWidget) self.label.setObjectName("label") self.horizontalLayout.addWidget(self.label) self.lineEdit = QtWidgets.QLineEdit(self.layoutWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth()) self.lineEdit.setSizePolicy(sizePolicy) self.lineEdit.setText("") self.lineEdit.setObjectName("lineEdit") self.horizontalLayout.addWidget(self.lineEdit) self.label_2 = QtWidgets.QLabel(self.layoutWidget) self.label_2.setObjectName("label_2") self.horizontalLayout.addWidget(self.label_2) self.comboBox_2 = QtWidgets.QComboBox(self.layoutWidget) self.comboBox_2.setObjectName("comboBox_2") self.comboBox_2.addItem("") self.comboBox_2.addItem("") self.comboBox_2.addItem("") self.comboBox_2.addItem("") self.horizontalLayout.addWidget(self.comboBox_2) self.label_3 = QtWidgets.QLabel(self.layoutWidget) self.label_3.setObjectName("label_3") self.horizontalLayout.addWidget(self.label_3) self.comboBox = QtWidgets.QComboBox(self.layoutWidget) self.comboBox.setObjectName("comboBox") self.horizontalLayout.addWidget(self.comboBox) self.verticalLayout.addLayout(self.horizontalLayout) spacerItem = QtWidgets.QSpacerItem(334, 65, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.pushButton = QtWidgets.QPushButton(self.layoutWidget) self.pushButton.setObjectName("pushButton") self.horizontalLayout_2.addWidget(self.pushButton) self.pushButton_2 = QtWidgets.QPushButton(self.layoutWidget) self.pushButton_2.setObjectName("pushButton_2") self.horizontalLayout_2.addWidget(self.pushButton_2) self.verticalLayout.addLayout(self.horizontalLayout_2) self.retranslateUi(newboy) self.pushButton.clicked.connect(newboy.addok) # type: ignore self.pushButton_2.clicked.connect(newboy.close) # type: ignore QtCore.QMetaObject.connectSlotsByName(newboy) def retranslateUi(self, newboy): _translate = QtCore.QCoreApplication.translate newboy.setWindowTitle(_translate("newboy", "Form")) self.label.setText(_translate("newboy", "姓名")) self.label_2.setText(_translate("newboy", "身份")) self.comboBox_2.setItemText(0, _translate("newboy", "機(jī)器人")) self.comboBox_2.setItemText(1, _translate("newboy", "軍火商")) self.comboBox_2.setItemText(2, _translate("newboy", "特種兵")) self.comboBox_2.setItemText(3, _translate("newboy", "電動(dòng)車(chē)")) self.label_3.setText(_translate("newboy", "崗位")) self.pushButton.setText(_translate("newboy", "確定")) self.pushButton_2.setText(_translate("newboy", "取消"))
5.生成管理成員的ui的代碼。rightclickfrom
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'rightclickfrom.ui' # # Created by: PyQt5 UI code generator 5.15.6 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Rrightclickform(object): def setupUi(self, Rrightclickform): Rrightclickform.setObjectName("Rrightclickform") Rrightclickform.resize(361, 256) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(Rrightclickform.sizePolicy().hasHeightForWidth()) Rrightclickform.setSizePolicy(sizePolicy) self.layoutWidget = QtWidgets.QWidget(Rrightclickform) self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 229, 176)) self.layoutWidget.setObjectName("layoutWidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label = QtWidgets.QLabel(self.layoutWidget) self.label.setObjectName("label") self.horizontalLayout.addWidget(self.label) self.comboBoxjiezou = QtWidgets.QComboBox(self.layoutWidget) self.comboBoxjiezou.setObjectName("comboBoxjiezou") self.comboBoxjiezou.addItem("") self.comboBoxjiezou.addItem("") self.comboBoxjiezou.addItem("") self.comboBoxjiezou.addItem("") self.comboBoxjiezou.addItem("") self.horizontalLayout.addWidget(self.comboBoxjiezou) self.label_2 = QtWidgets.QLabel(self.layoutWidget) self.label_2.setObjectName("label_2") self.horizontalLayout.addWidget(self.label_2) self.comboBoxbiaoji = QtWidgets.QComboBox(self.layoutWidget) self.comboBoxbiaoji.setObjectName("comboBoxbiaoji") self.comboBoxbiaoji.addItem("") self.comboBoxbiaoji.addItem("") self.comboBoxbiaoji.addItem("") self.comboBoxbiaoji.addItem("") self.horizontalLayout.addWidget(self.comboBoxbiaoji) self.verticalLayout.addLayout(self.horizontalLayout) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.pushButton = QtWidgets.QPushButton(self.layoutWidget) self.pushButton.setObjectName("pushButton") self.verticalLayout.addWidget(self.pushButton) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem1) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.pushButton_2 = QtWidgets.QPushButton(self.layoutWidget) self.pushButton_2.setObjectName("pushButton_2") self.horizontalLayout_2.addWidget(self.pushButton_2) self.pushButton_3 = QtWidgets.QPushButton(self.layoutWidget) self.pushButton_3.setObjectName("pushButton_3") self.horizontalLayout_2.addWidget(self.pushButton_3) self.verticalLayout.addLayout(self.horizontalLayout_2) self.retranslateUi(Rrightclickform) self.pushButton.clicked.connect(Rrightclickform.delputbutton) # type: ignore self.pushButton_2.clicked.connect(Rrightclickform.jieok) # type: ignore self.pushButton_3.clicked.connect(Rrightclickform.close) # type: ignore self.pushButton.clicked.connect(Rrightclickform.close) # type: ignore self.pushButton_2.clicked.connect(Rrightclickform.close) # type: ignore QtCore.QMetaObject.connectSlotsByName(Rrightclickform) def retranslateUi(self, Rrightclickform): _translate = QtCore.QCoreApplication.translate Rrightclickform.setWindowTitle(_translate("Rrightclickform", "人員狀態(tài)")) self.label.setText(_translate("Rrightclickform", "借走")) self.comboBoxjiezou.setItemText(0, _translate("Rrightclickform", "無(wú)")) self.comboBoxjiezou.setItemText(1, _translate("Rrightclickform", "自行車(chē)1")) self.comboBoxjiezou.setItemText(2, _translate("Rrightclickform", "籃球")) self.comboBoxjiezou.setItemText(3, _translate("Rrightclickform", "庫(kù)房鑰匙東")) self.comboBoxjiezou.setItemText(4, _translate("Rrightclickform", "新建項(xiàng)目")) self.label_2.setText(_translate("Rrightclickform", "標(biāo)記")) self.comboBoxbiaoji.setItemText(0, _translate("Rrightclickform", "休假")) self.comboBoxbiaoji.setItemText(1, _translate("Rrightclickform", "輪休")) self.comboBoxbiaoji.setItemText(2, _translate("Rrightclickform", "醫(yī)院")) self.comboBoxbiaoji.setItemText(3, _translate("Rrightclickform", "出差")) self.pushButton.setText(_translate("Rrightclickform", "刪除按鈕??!")) self.pushButton_2.setText(_translate("Rrightclickform", "確定")) self.pushButton_3.setText(_translate("Rrightclickform", "取消"))
6.生成管理崗位的ui的代碼。
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'manager_ui_gangwei.ui' # # Created by: PyQt5 UI code generator 5.15.6 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, QtGui, QtWidgets class Ui_widget(object): def setupUi(self, widget): widget.setObjectName("widget") widget.resize(443, 174) self.gridLayout = QtWidgets.QGridLayout(widget) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label = QtWidgets.QLabel(widget) self.label.setObjectName("label") self.horizontalLayout.addWidget(self.label) self.lineEdit = QtWidgets.QLineEdit(widget) self.lineEdit.setObjectName("lineEdit") self.horizontalLayout.addWidget(self.lineEdit) self.pushButton = QtWidgets.QPushButton(widget) self.pushButton.setObjectName("pushButton") self.horizontalLayout.addWidget(self.pushButton) self.verticalLayout.addLayout(self.horizontalLayout) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label_2 = QtWidgets.QLabel(widget) self.label_2.setObjectName("label_2") self.horizontalLayout_2.addWidget(self.label_2) self.comboBox = QtWidgets.QComboBox(widget) self.comboBox.setObjectName("comboBox") self.horizontalLayout_2.addWidget(self.comboBox) self.pushButton_2 = QtWidgets.QPushButton(widget) self.pushButton_2.setObjectName("pushButton_2") self.horizontalLayout_2.addWidget(self.pushButton_2) self.horizontalLayout_2.setStretch(0, 1) self.horizontalLayout_2.setStretch(1, 2) self.horizontalLayout_2.setStretch(2, 1) self.verticalLayout.addLayout(self.horizontalLayout_2) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.retranslateUi(widget) self.pushButton.clicked.connect(widget.add_gangwei_ok) # type: ignore self.pushButton_2.clicked.connect(widget.del_gangwei_ok) # type: ignore QtCore.QMetaObject.connectSlotsByName(widget) def retranslateUi(self, widget): _translate = QtCore.QCoreApplication.translate widget.setWindowTitle(_translate("widget", "崗位管理")) self.label.setText(_translate("widget", "新增崗位")) self.pushButton.setText(_translate("widget", "確定")) self.label_2.setText(_translate("widget", "刪除崗位")) self.pushButton_2.setText(_translate("widget", "確定"))
到此這篇關(guān)于Python實(shí)現(xiàn)功能完整的個(gè)人員管理程序的文章就介紹到這了,更多相關(guān)Python人員管理內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python paramiko遠(yuǎn)程服務(wù)器終端操作過(guò)程解析
這篇文章主要介紹了python paramiko遠(yuǎn)程服務(wù)器終端操作過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-12-12Python基于property實(shí)現(xiàn)類(lèi)的特性操作示例
這篇文章主要介紹了Python基于property實(shí)現(xiàn)類(lèi)的特性,結(jié)合實(shí)例形式分析了使用property實(shí)現(xiàn)類(lèi)的特性相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下2018-06-06Python中等待5秒并暫停執(zhí)行的方法總結(jié)
Python 具有各種功能和庫(kù)來(lái)創(chuàng)建交互式應(yīng)用程序,用戶(hù)可以在其中提供輸入和響應(yīng), 我們可以創(chuàng)建需要暫停應(yīng)用程序執(zhí)行的情況,本文主要和大家分享三個(gè)Python 中等待 5 秒并暫停執(zhí)行的方法,有需要的可以參考下2023-10-10詳解python如何通過(guò)numpy數(shù)組處理圖像
Numpy?是?Python?中科學(xué)計(jì)算的核心庫(kù),NumPy?這個(gè)詞來(lái)源于?Numerical?和?Python?兩個(gè)單詞。它提供了一個(gè)高性能的多維數(shù)組對(duì)象,以及大量的庫(kù)函數(shù)和操作,可以幫助程序員輕松地進(jìn)行數(shù)值計(jì)算,廣泛應(yīng)用于機(jī)器學(xué)習(xí)模型、圖像處理和計(jì)算機(jī)圖形學(xué)、數(shù)學(xué)任務(wù)等領(lǐng)域2022-03-03