Tkinter实现人员管理系统(mongodb版)

前言

Tkinter是python内置的标准GUI库,基于Tkinter实现了简易人员管理系统,所用数据库为Mongodb

代码

时间宝贵!直接上代码!(主要是懒,后续一点点精修8)

from tkinter import *
from tkinter.messagebox import *
from tkinter import ttk
import pymongo
import tkinter as tk
import re
import time
import datetime

import pandas as pd
from tkinter import filedialog
from PIL import ImageTk,Image
import tkinter

#连接数据库
client = pymongo.MongoClient(host="localhost", port=27017)
db = client.sys
col = db.user
#创建窗口
root = Tk()
root.geometry('900x700')
root.title('人员管理系统')
#表头
img =Image.open(r'C:\Users\apple\Desktop\image.jpg')
img = img.resize((900,68),Image.ANTIALIAS)
img = ImageTk.PhotoImage(img)
top=Label(root, text='人员管理系统',image=img,fg='black',font=('楷体', 20),compound='center', bitmap='error')
top.pack(ipady=0,side=TOP, fill='x')
#变量
sid = StringVar()
name = StringVar()
age = StringVar()
salary = StringVar()
phone = StringVar()
birthday = StringVar()


#控制函数

def add():
    global info
    info=Toplevel()
    info.title("添加信息")
    info.geometry('400x400') 
    button1=Button(info, text="确认",command=appendInfo,font=("黑体", 12)).place(relx=0.4, rely=0.8, width=100)
    Label(info, text="工号:").place(relx=0.2, rely=0.1, relwidth=0.1)
    Label(info, text="姓名:").place(relx=0.2, rely=0.2, relwidth=0.1)
    Label(info, text="年龄:").place(relx=0.2, rely=0.3, relwidth=0.1)
    Label(info, text="薪资:").place(relx=0.2, rely=0.4, relwidth=0.1)
    Label(info, text="电话:").place(relx=0.2, rely=0.5, relwidth=0.1)
    Label(info, text="生日:").place(relx=0.2, rely=0.6, relwidth=0.1)
    text1=Entry(info, textvariable=sid).place(relx=0.3, rely=0.1, relwidth=0.45, height=25)
    sid.set("")
    text2=Entry(info, textvariable=name).place(relx=0.3, rely=0.2, relwidth=0.45, height=25)
    name.set("")
    text3=Entry(info, textvariable=age).place(relx=0.3, rely=0.3, relwidth=0.45, height=25)
    age.set("")
    text4=Entry(info, textvariable=salary).place(relx=0.3, rely=0.4, relwidth=0.45, height=25)
    salary.set("")
    text5=Entry(info, textvariable=phone).place(relx=0.3, rely=0.5, relwidth=0.45, height=25)
    phone.set("")
    text6=Entry(info, textvariable=birthday).place(relx=0.3, rely=0.6, relwidth=0.45, height=25)
    birthday.set("")
    info.bind('<Return>',pas8)
#     info.bind_all('<KeyPress-Up>',movetriangle)
#     info.bind_all('<KeyPress-Down>',movetriangle)
#     info.bind_all('<KeyPress-Left>',movetriangle)
#     .bind_all('<KeyPress-Right>',movetriangle)
    
    
def pitch_on():
    global info
    info=Toplevel()
    info.title("删除信息")
    info.geometry('400x400')
    Label(info, text="是否确定删除以下信息",font=('楷体', 15)).place(relx=0.2, rely=0.01, relwidth=0.6)
    Label(info, text="工号:").place(relx=0.2, rely=0.1, relwidth=0.1)
    Label(info, text="姓名:").place(relx=0.2, rely=0.2, relwidth=0.1)
    Label(info, text="年龄:").place(relx=0.2, rely=0.3, relwidth=0.1)
    Label(info, text="薪资:").place(relx=0.2, rely=0.4, relwidth=0.1)
    Label(info, text="电话:").place(relx=0.2, rely=0.5, relwidth=0.1)
    Label(info, text="生日:").place(relx=0.2, rely=0.6, relwidth=0.1)
    text1=Entry(info, textvariable=sid,state='disable').place(relx=0.3, rely=0.1, relwidth=0.45, height=25)
    sid.set(sf[0])
    text2=Entry(info, textvariable=name,state='disable').place(relx=0.3, rely=0.2, relwidth=0.45, height=25)
    name.set(sf[1])
    text3=Entry(info, textvariable=age,state='disable').place(relx=0.3, rely=0.3, relwidth=0.45, height=25)
    age.set(sf[2])
    text4=Entry(info, textvariable=salary,state='disable').place(relx=0.3, rely=0.4, relwidth=0.45, height=25)
    salary.set(sf[3])
    text5=Entry(info, textvariable=phone,state='disable').place(relx=0.3, rely=0.5, relwidth=0.45, height=25)
    phone.set(sf[4])
    text6=Entry(info, textvariable=birthday,state='disable').place(relx=0.3, rely=0.6, relwidth=0.45, height=25)
    birthday.set(sf[5])
    button1=Button(info, text="确认",command=deleteInfo).place(relx=0.2, rely=0.8, width=100)
    button2=Button(info, text="关闭",command=des).place(relx=0.6, rely=0.8, width=100)
    info.bind('<Return>',pas33)
    
def information2():
    global info
    info=Toplevel()
    info.title("详细信息")
    info.</
  • 7
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值