kongzhi.py#主控模块
from socket import *
from tkinter import *
from ts_denglu import *
s = socket()
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
def main():
root = Tk()
sw = root.winfo_screenwidth()#屏幕宽度
sh = root.winfo_screenheight()#屏幕高度
ww = 450
wh = 250
x = (sw-ww)/2
y = (sh-wh)/2
root.geometry("%dx%d+%d+%d"%(ww,wh,x,y))
root.title('图书管理系统')
root.resizable(width=False, height=False)
denglu = DengLu(root,s)
root.mainloop()
if __name__ == '__main__':
main()
ts_denglu.py #登录模块
'''
name : fushibo
date : 2018-5-30
图书管理系统登录页面
'''
from tkinter import *
from tkinter import messagebox
from main_ye import *
import sys
class DengLu(object):
def __init__(self,m=None,s=None):
self.root = m
self.s = s
while True:
try:
self.s.connect(('127.0.0.1',9028))
break
except:
messagebox.showwarning('error','无网络链接!')
self.deng()
def deng(self):
self.frame = Frame(width=450,height=250)
self.frame.pack()
Label(self.frame).grid(row=0,sticky=W)
Label(self.frame, text='管理员账号:', fg='blue', font=15)\
.grid(row = 3, sticky=W,pady=10)
Label(self.frame, text='管理员密码:', fg='blue', font=15)\
.grid(row = 4, sticky=W,pady=10)
Label(self.frame, text='管理员类别:', fg='blue', font=15)\
.grid(row = 5, sticky=W,pady=10)
self.a1 = StringVar()
self.a2 = StringVar()
self.b1 = Entry(self.frame, textvar=self.a1,width=25)
self.b2 = Entry(self.frame, textvar=self.a2,width=25,show='*')
self.b1.grid(row = 3,column=1,sticky=E)
self.b2.grid(row = 4,column=1,sticky=E)
self.w = ttk.Combobox(self.frame,width=23,values=['普通管理员','高级管理员','超级管理员'])
self.w.grid(row = 5,column=1,sticky=E)
self.w.current(0)
self.c1 = Button(self.frame, text='登录',font=15,
background='#C6D6A7',activebackground='#1AD8E8',width=10, command=self.deng_lu).\
grid(row = 6, sticky=W,pady=10)
self.c2 = Button(self.frame, text='退出', font=15,
background='#C6D6A7',activebackground='#1AD8E8', width=10, command=self.root.quit).\
grid(row = 6,column=1,sticky=E)
def deng_lu(self):
try:
usr_name = self.a1.get()
usr_pwd = self.a2.get()
usr_class = self.w.get()
if len(usr_name) < 1 or len(usr_pwd) < 1 or len(usr_class) < 1:
messagebox.showerror('图书管理系统','您输入的内容不能为空!')
return
self.b1.delete(0,END)
self.b2.delete(0,END)
if usr_class == '普通管理员':
usr_class = 1
elif usr_class == '高级管理员':
usr_class = 2
elif usr_class == '超级管理员':
usr_class = 3
msg = 'X {} {} {}'.format(usr_name,usr_pwd,usr_class)
self.s.send(msg.encode())
except:
messagebox.showerror('图书管理系统','无网络链接!')
data = self.s.recv(128).decode()
if data == 'OK':
self.root.destroy()
Ye_mian()
else:
messagebox.showerror('图书管理系统','用户名或密码错误!')
return
main_ye.py#主页面模块
#!/usr/bin/env python3
# coding=utf-8
'''
name : fushibo
date : 2018-5-30
图书管理系统主页面
'''
from tkinter import *
from zi_yemian01 import *
import sys
from PIL import Image,ImageTk
class Ye_mian():
def __init__(self):
self.root = Tk()
canvas = Canvas(self.root,width = 890,height = 670, bg = 'white')
self.image = Image.open("./image/ssss.jpg")
self.im = ImageTk.PhotoImage(self.image)
canvas.create_image(450,280,image = self.im)
canvas.pack()
self.sw = self.root.winfo_screenwidth()#屏幕宽度
self.sh = self.root.winfo_screenheight()#屏幕高度
self.x = (self.sw-890)/2
self.y = (self.sh-670)/2
self.root.geometry("%dx%d+%d+%d"%(890,670,self.x,self.y))
self.root.resizable(False,False)
self.root.title('欢迎进入图书管理系统--菜单')
Label(self.root,background='#FFFFFF',text='三更灯火五更鸡',font=('楷体',16,"normal"),fg='#2CEAE0',justify=LEFT).place(x=250,y=55)
Label(self.root,background='#FFFFFF',text='正是男儿读书时',font=('楷体',16,"normal"),fg='#24ED76',justify=LEFT).place(x=400,y=190)
Label(self.root,background='#FFFFFF',text='黑发不知勤学早',font=('楷体',16,"normal"),fg='#08D6E8',justify=LEFT).place(x=550,y=320)
Label(self.root,background='#FFFFFF',text='白首方悔读书迟',font=('楷体',16,"normal"),fg='#D8BC2E',justify=LEFT).place(x=700,y=445)
Button(self.root,text='日常工作',command=self.gongzuo,font=("黑体",16,"normal"),background='#D2FCFB',activebackground='#1AD8E8')\
.place(x=40,y=10,width=160,height=130)
Button(self.root,text='资料维护',command=self.ziliao,font=("黑体",16,"normal"),background='#DAF4E6',activebackground='#1AD8E8')\
.place(x=200,y=140,width=160,height=130)
Button(self.root,text='历史查询',command=self.lishi,font=("黑体",16,"normal"),background='#E2EFD3',activebackground='#1AD8E8')\
.place(x=360,y=270,width=160,height=130)
Button(self.root,text='系统管理',command=self.xitong,font=("黑体",16,"normal"),background='#F0E4B2',activebackground='#1AD8E8')\
.place(x=520,y=400,width=160,height=130)
Button(self.root,text='安全退出',command=self.tuichu,font=("黑体",16,"normal"),background='#7EE8A7',activebackground='#1AD8E8')\
.place(x=680,y=530,width=160,height=130)
self.root.mainloop()
def gongzuo(self):
self.root.destroy()
Main01_ye()
def ziliao(self):
self.root.destroy()
Main02_ye()
def lishi(self):
self.root.destroy()
Main03_ye()
def xitong(self):
self.root.destroy()
Main04_ye()
def tuichu(self):
sys.exit('欢迎再次使用!')
class Main01_ye(object):#日常工作
def __init__(self):
self.root = Tk()
sw = self.root.winfo_screenwidth()#屏幕宽度
sh = self.root.winfo_screenheight()#屏幕高度
image = Image.open(r'./image/ffff.jpg')
background_image = ImageTk.PhotoImage(image)
ww = background_image.width()
wh = background_image.height()
x = (sw-ww)/2
y = (sh-wh)/2
self.root.geometry("%dx%d+%d+%d"%(ww,wh,x,y))
self.root.title('欢迎进入图书管理系统--日常工作')
background_label = Label(self.root, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.root.resizable(False,False)
self.guanli()
self.root.mainloop()
def guanli(self):
self.ts_jieyue = Ts_JYFrame(self.root)
self.ts_guihuan = Ts_GHFrame(self.root)
self.ts_fanjin = Ts_FJFrame(self.root)
self.ts_xiaoshou = Ts_XSFrame(self.root)
self.ts_chongzhi = Ts_CZFrame(self.root)
self.ts_guanyu = Ts_GYFrame(self.root)
self.ts_fanhui = Ts_FHFrame(self.root)
self.ts_jieyue.pack()#默认显示
menubar = Menu(self.root,background='#C6D6A7')
menubar.add_command(label='图书借阅',font=18,activebackground='#9BD6CB',command=self.jieyue_data)
menubar.add_command(label='图书归还',font=18,activebackground='#9BD6CB',command=self.guihuan_data)
menubar.add_command(label='缴纳罚金',font=18,activebackground='#9BD6CB',command=self.fajin_data)
menubar.add_command(label='图书销售',font=18,activebackground='#9BD6CB',command=self.xiaoshou_data)
menubar.add_command(label='信用充值',font=18,activebackground='#9BD6CB',command=self.chongzhi_data)
menubar.add_command(label='关于我们',font=18,activebackground='#9BD6CB',command=self.guanyu_data)
menubar.add_command(label='返回主页',font=18,activebackground='#C90000',command=self.fanhui_data)
self.root['menu'] = menubar#设置菜单
def jieyue_data(self):
self.ts_jieyue.pack()
self.ts_guihuan.pack_forget()
self.ts_fanjin.pack_forget()
self.ts_xiaoshou.pack_forget()
self.ts_chongzhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def guihuan_data(self):
self.ts_jieyue.pack_forget()
self.ts_guihuan.pack()
self.ts_fanjin.pack_forget()
self.ts_xiaoshou.pack_forget()
self.ts_chongzhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def fajin_data(self):
self.ts_jieyue.pack_forget()
self.ts_guihuan.pack_forget()
self.ts_fanjin.pack()
self.ts_xiaoshou.pack_forget()
self.ts_chongzhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def xiaoshou_data(self):
self.ts_jieyue.pack_forget()
self.ts_guihuan.pack_forget()
self.ts_fanjin.pack_forget()
self.ts_xiaoshou.pack()
self.ts_chongzhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def chongzhi_data(self):
self.ts_jieyue.pack_forget()
self.ts_guihuan.pack_forget()
self.ts_fanjin.pack_forget()
self.ts_xiaoshou.pack_forget()
self.ts_chongzhi.pack()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def guanyu_data(self):
self.ts_jieyue.pack_forget()
self.ts_guihuan.pack_forget()
self.ts_fanjin.pack_forget()
self.ts_xiaoshou.pack_forget()
self.ts_chongzhi.pack_forget()
self.ts_guanyu.pack()
self.ts_fanhui.pack_forget()
def fanhui_data(self):
self.ts_jieyue.pack_forget()
self.ts_guihuan.pack_forget()
self.ts_fanjin.pack_forget()
self.ts_xiaoshou.pack_forget()
self.ts_chongzhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack()
self.root.destroy()
Ye_mian()
class Main02_ye(object):#资料维护
def __init__(self):
self.root = Tk()
sw = self.root.winfo_screenwidth()#屏幕宽度
sh = self.root.winfo_screenheight()#屏幕高度
image = Image.open(r'./image/ffff.jpg')
background_image = ImageTk.PhotoImage(image)
ww = background_image.width()
wh = background_image.height()
x = (sw-ww)/2
y = (sh-wh)/2
self.root.geometry("%dx%d+%d+%d"%(ww,wh,x,y))
self.root.title('欢迎进入图书管理系统--资料维护')
background_label = Label(self.root, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.root.resizable(False,False)
self.guanli()
self.root.mainloop()
def guanli(self):
self.ts_caigou = Ts_CGFrame(self.root)
self.ts_baosun = Ts_BSFrame(self.root)
self.ts_duzhe = Ts_DZFrame(self.root)
self.ts_guanyu = Ts_GYFrame(self.root)
self.ts_fanhui = Ts_FHFrame(self.root)
self.ts_caigou.pack()#默认显示
menubar = Menu(self.root,background='#C6D6A7')
menubar.add_command(label='图书采购',font=18,activebackground='#9BD6CB',command=self.CG_data)
menubar.add_command(label='图书报损',font=18,activebackground='#9BD6CB',command=self.baosun_data)
menubar.add_command(label='读者管理',font=18,activebackground='#9BD6CB',command=self.duzhe_data)
menubar.add_command(label='关于我们',font=18,activebackground='#9BD6CB',command=self.guanyu_data)
menubar.add_command(label='返回主页',font=18,activebackground='#C90000',command=self.fanhui_data)
self.root['menu'] = menubar#设置菜单
def CG_data(self):
self.ts_caigou.pack()
self.ts_baosun.pack_forget()
self.ts_duzhe.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def baosun_data(self):
self.ts_caigou.pack_forget()
self.ts_baosun.pack()
self.ts_duzhe.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def duzhe_data(self):
self.ts_caigou.pack_forget()
self.ts_baosun.pack_forget()
self.ts_duzhe.pack()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def guanyu_data(self):
self.ts_caigou.pack_forget()
self.ts_baosun.pack_forget()
self.ts_duzhe.pack_forget()
self.ts_guanyu.pack()
self.ts_fanhui.pack_forget()
def fanhui_data(self):
self.ts_caigou.pack_forget()
self.ts_baosun.pack_forget()
self.ts_duzhe.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack()
self.root.destroy()
Ye_mian()
class Main03_ye(object):#历史查询
def __init__(self):
self.root = Tk()
sw = self.root.winfo_screenwidth()#屏幕宽度
sh = self.root.winfo_screenheight()#屏幕高度
image = Image.open(r'./image/ffff.jpg')
background_image = ImageTk.PhotoImage(image)
ww = background_image.width()
wh = background_image.height()
x = (sw-ww)/2
y = (sh-wh)/2
self.root.geometry("%dx%d+%d+%d"%(ww,wh,x,y))
self.root.title('欢迎进入图书管理系统--历史查询')
background_label = Label(self.root, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.root.resizable(False,False)
self.guanli()
self.root.mainloop()
def guanli(self):
self.ts_chaxun = Ts_TCFrame(self.root)
self.ts_ducha = Ts_DCFrame(self.root)
self.ts_jiecha = Ts_JCFrame(self.root)
self.ts_facha = Ts_FCFrame(self.root)
self.ts_xiaocha = Ts_XCFrame(self.root)
self.ts_guanyu = Ts_GYFrame(self.root)
self.ts_fanhui = Ts_FHFrame(self.root)
self.ts_chaxun.pack()#默认显示
menubar = Menu(self.root,background='#C6D6A7')
menubar.add_command(label='图书查询',font=18,activebackground='#9BD6CB',command=self.chaxun_data)
menubar.add_command(label='读者查询',font=18,activebackground='#9BD6CB',command=self.ducha_data)
menubar.add_command(label='借阅查询',font=18,activebackground='#9BD6CB',command=self.jiecha_data)
menubar.add_command(label='罚金查询',font=18,activebackground='#9BD6CB',command=self.facha_data)
menubar.add_command(label='销售查询',font=18,activebackground='#9BD6CB',command=self.xiaocha_data)
menubar.add_command(label='关于我们',font=18,activebackground='#9BD6CB',command=self.guanyu_data)
menubar.add_command(label='返回主页',font=18,activebackground='#C90000',command=self.fanhui_data)
self.root['menu'] = menubar#设置菜单
def chaxun_data(self):
self.ts_chaxun.pack()
self.ts_ducha.pack_forget()
self.ts_jiecha.pack_forget()
self.ts_facha.pack_forget()
self.ts_xiaocha.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def ducha_data(self):
self.ts_chaxun.pack_forget()
self.ts_ducha.pack()
self.ts_jiecha.pack_forget()
self.ts_facha.pack_forget()
self.ts_xiaocha.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def jiecha_data(self):
self.ts_chaxun.pack_forget()
self.ts_ducha.pack_forget()
self.ts_jiecha.pack()
self.ts_facha.pack_forget()
self.ts_xiaocha.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def facha_data(self):
self.ts_chaxun.pack_forget()
self.ts_ducha.pack_forget()
self.ts_jiecha.pack_forget()
self.ts_facha.pack()
self.ts_xiaocha.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def xiaocha_data(self):
self.ts_chaxun.pack_forget()
self.ts_ducha.pack_forget()
self.ts_jiecha.pack_forget()
self.ts_facha.pack_forget()
self.ts_xiaocha.pack()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def guanyu_data(self):
self.ts_chaxun.pack_forget()
self.ts_ducha.pack_forget()
self.ts_jiecha.pack_forget()
self.ts_facha.pack_forget()
self.ts_xiaocha.pack_forget()
self.ts_guanyu.pack()
self.ts_fanhui.pack_forget()
def fanhui_data(self):
self.ts_chaxun.pack_forget()
self.ts_ducha.pack_forget()
self.ts_jiecha.pack_forget()
self.ts_facha.pack_forget()
self.ts_xiaocha.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack()
self.root.destroy()
Ye_mian()
class Main04_ye(object):#系统管理
def __init__(self):
self.root = Tk()
sw = self.root.winfo_screenwidth()#屏幕宽度
sh = self.root.winfo_screenheight()#屏幕高度
image = Image.open(r'./image/ffff.jpg')
background_image = ImageTk.PhotoImage(image)
ww = background_image.width()
wh = background_image.height()
x = (sw-ww)/2
y = (sh-wh)/2
self.root.geometry("%dx%d+%d+%d"%(ww,wh,x,y))
self.root.title('欢迎进入图书管理系统--系统管理')
background_label = Label(self.root, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.root.resizable(False,False)
self.guanli()
self.root.mainloop()
def guanli(self):
self.ts_yuangong = Ts_YGFrame(self.root)
self.ts_zhuxiao = Ts_ZXFrame(self.root)
self.ts_shezhi = Ts_SZFrame(self.root)
self.ts_guanyu = Ts_GYFrame(self.root)
self.ts_fanhui = Ts_FHFrame(self.root)
self.ts_yuangong.pack()#默认显示
menubar = Menu(self.root,background='#C6D6A7')
menubar.add_command(label='员工管理',font=18,activebackground='#9BD6CB',command=self.yuangong_data)
menubar.add_command(label='账户管理',font=18,activebackground='#9BD6CB',command=self.zhuxiao_data)
menubar.add_command(label='系统设置',font=18,activebackground='#9BD6CB',command=self.shezhi_data)
menubar.add_command(label='关于我们',font=18,activebackground='#9BD6CB',command=self.guanyu_data)
menubar.add_command(label='返回主页',font=18,activebackground='#C90000',command=self.fanhui_data)
self.root['menu'] = menubar#设置菜单
def yuangong_data(self):
self.ts_yuangong.pack()
self.ts_zhuxiao.pack_forget()
self.ts_shezhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def zhuxiao_data(self):
self.ts_yuangong.pack_forget()
self.ts_zhuxiao.pack()
self.ts_shezhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def shezhi_data(self):
self.ts_yuangong.pack_forget()
self.ts_zhuxiao.pack_forget()
self.ts_shezhi.pack()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack_forget()
def guanyu_data(self):
self.ts_yuangong.pack_forget()
self.ts_zhuxiao.pack_forget()
self.ts_shezhi.pack_forget()
self.ts_guanyu.pack()
self.ts_fanhui.pack_forget()
def fanhui_data(self):
self.ts_yuangong.pack_forget()
self.ts_zhuxiao.pack_forget()
self.ts_shezhi.pack_forget()
self.ts_guanyu.pack_forget()
self.ts_fanhui.pack()
self.root.destroy()
Ye_mian()
zi_yemian.py#子页面模块
#!/usr/bin/env python3
# coding=utf-8
'''
name : fushibo
date : 2018-5-30
图书管理系统子页面
'''
from tkinter import *
from tkinter import messagebox
from kongzhi import s
from tkinter import ttk
import re
import sys
from PIL import Image,ImageTk
try:
s.connect(('127.0.0.1',9028))
except:
root = Tk()
sw = root.winfo_screenwidth()#屏幕宽度
sh = root.winfo_screenheight()#屏幕高度
ww = 450
wh = 250
x = (sw-ww)/2
y = (sh-wh)/2
root.geometry("%dx%d+%d+%d"%(ww,wh,x,y))
root.title('图书管理系统')
root.resizable(width=False, height=False)
messagebox.showwarning('error','无网络链接!')
sys.exit()
#第一部分
class Ts_JYFrame(Frame):#图书借阅
def __init__(self,m=None):
Frame.__init__(self,m,background='#FFFFFF')
self.s = s
self.root = m
self.jieyueren_id = StringVar()
self.book_id = StringVar()
self.jieyue_date = StringVar()
self.guihuan_date = StringVar()
self.start()
def start(self):
Label(self,background='#FFFFFF').grid(row=0,sticky=W,pady=40)
Label(self,background='#FFFFFF',text='身份证号码',font=18,fg='#353E40').grid(row=4,sticky=W,pady=10)
self.a1=Entry(self,textvariable=self.jieyueren_id)
self.a1.grid(row=4,column=1,sticky=E)
Label(self,background='#FFFFFF',text='图书ID',font=18,fg='#353E40').grid(row=6,sticky=W,pady=10)
self.a2=Entry(self,textvariable=self.book_id)
self.a2.grid(row=6,column=1,sticky=E)
Label(self,background='#FFFFFF',text='归还时间',font=18,fg='#353E40').grid(row=8,sticky=W,pady=10)
self.a3=Entry(self,textvariable=self.guihuan_date)
self.a3.grid(row=8,column=1,sticky=E)
Button(self,text='确定',command=self.luru,font=18,background='#C6D6A7',activebackground='#1AD8E8')\
.grid(row=10,column=0,sticky=W,pady=10)
Button(self,text='清空',command=self.quxiao,font=18,background='#C6D6A7',activebackground='#1AD8E8')\
.grid(row=10,column=1,sticky=W,pady=10)
def luru(self):
try:
jieyueren_id = self.jieyueren_id.get().strip()
book_id = self.book_id.get().strip()
guihuan_date = self.guihuan_date.get().strip()
self.a1.delete(0,END)
self.a2.delete(0,END)
self.a3.delete(0,END)
msg = 'A {} {} {}'.format(jieyueren_id,book_id,guihuan_date)
if re.search('[~`,*!%);@\:\\\(#$^&_\'=+.>\|}\[{\]"?/<]', msg):
messagebox.showerror('图书管理系统','您输入的内容不规范!')
return
elif 1 <= len(jieyueren_id) and len(jieyueren_id) != 18:
messagebox.showerror('图书管理系统','您输入的身份证有误!')
return
elif len(jieyueren_id) < 1 or len(book_id) < 1 or len(guihuan_date) < 1:
messagebox.showerror('图书管理系统','您输入的内容不能为空!')
return
else:
self.s.send(msg.encode())
except:
messagebox.showerror('图书管理系统','无网络链接!')
data = self.s.recv(128).decode()
if data == 'OK':
messagebox.showerror('图书管理系统','借书成功!')
elif data =='OUT':
messagebox.showerror('图书管理系统','没有库存,请及时采购!')
elif data =='SAS':
messagebox.showerror('图书管理系统','您已借过该书!')
else:
messagebox.showerror('图书管理系统','借书失败!')
def quxiao(self):
self.a1.delete(0,END)
self.a2.delete(0,END)
self.a3.delete(0,END)
class Ts_GHFrame(Frame):#归还图书
def __init__(self,m=None):
Frame.__init__(self,background='#FFFFFF')
self.s = s
self.root = m
self.jieyueren_id = StringVar()
self.book_name = StringVar()
self.guihuan_date = StringVar()
self.start()
def start(self):
Label(self,background='#FFFFFF').grid(row=0,sticky=W,pady=40)
Label(self,background='#FFFFFF',text='借阅人身份证号码',font=18,fg='#353E40').grid(row=2,sticky=W,pady=10)
self.a1=Entry(self,textvariable=self.jieyueren_id)
self.a1.grid(row=2,column=1,sticky=E)
Label(self,background='#FFFFFF',text='图书ID',font=18,fg='#353E40').grid(row=4,sticky=W,pady=10)
self.a2=Entry(self,textvariable=self.book_name)
self.a2.grid(row=4,column=1,sticky=E)
Label(self,background='#FFFFFF',text='借书时间',font=18,fg='#353E40').grid(row=6,sticky=W,pady=10)
self.a3=Entry(self,textvariable=self.guihuan_date)
self.a3.grid(row=6,column=1,sticky=E)
Button(self,text='确认',command=self.luru,font=18,background='#C6D6A7',activebackground='#1AD8E8')\
.grid(row=8,column=0,sticky=W,pady=5)
Button(self,text='清空',command=self.quxiao,font=18,background='#C6D6A7',activebackground='#1AD8E8')\
.grid(row=8,column=1,sticky=W,pady=10)
def luru(self):
try:
jieyueren_id = self.jieyueren_id.get().strip()
book_name = self.book_name.get().strip()
guihuan_date = self.guihuan_date.get().strip()
self.a1.delete(0,END)
self.a2.delete(0,END)
self.a3.delete(0,END)
msg = 'B {} {} {}'.format(jieyueren_id,book_name,guihuan_date)
if re.search('[~`,*!%);@\:\\\(#$^&_\'=+.>\|}\[{\]"?/<]', msg):
messagebox.showerror('图书管理系统','您输入的内容不规范!')
return
elif 1 <= len(jieyueren_id) and len(jieyueren_id) != 18:
messagebox.showerror('图书管理系统','您输入的身份证有误!')
return
elif len(jieyueren_id) < 1 or len(book_name) < 1 or len(guihuan_date) < 1 :
messagebox.showerror('图书管理系统','您输入的内容不能为空!')
return
else:
self.s.send(msg.encode())
except Exception as e:
print(e)
messagebox.showerror('图书管理系统','无网络链接!')
data = self.s.recv(128).decode()
data = data.split(' ')
print(data)
if data[0] == 'OK':
me