⽤python3做⼀个图书管理系统(图形⽤户界⾯:tkinter)
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.title('图书管理系统')
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):
< = m
self.s = s
while True:
try:
t(('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()
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='*')
id(row = 3,column=1,sticky=E)
id(row = 4,column=1,sticky=E)
self.w = ttk.Combobox(self.frame,width=23,values=['普通管理员','⾼级管理员','超级管理员'])
id(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, quit).\            grid(row = 6,column=1,sticky=E)
def deng_lu(self):
try:
usr_name = ()
usr_pwd = ()
usr_class = ()
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.de())
关于python的书
except:
messagebox.showerror('图书管理系统','⽆⽹络链接!')
data = v(128).decode()
if data == 'OK':
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):
< = Tk()
canvas = ,width = 890,height = 670, bg = 'white')
self.image = Image.open("./image/ssss.jpg")
self.im = ImageTk.PhotoImage(self.image)
canvas.pack()
self.sw = winfo_screenwidth()#屏幕宽度
self.sh = winfo_screenheight()#屏幕⾼度
self.x = (self.sw-890)/2
self.y = (self.sh-670)/2
,background='#FFFFFF',text='三更灯⽕五更鸡',font=('楷体',16,"normal"),fg='#2CEAE0',justify=LEFT).place(x=250,y=55)
,background='#FFFFFF',text='正是男⼉读书时',font=('楷体',16,"normal"),fg='#24ED76',justify=LEFT).place(x=400,y=190)        ,background='#FFFFFF',text='⿊发不知勤学早',font=('楷体',16,"normal"),fg='#08D6E8',justify=LEFT).place(x=550,y=320)        ,background='#FFFFFF',text='⽩⾸⽅悔读书迟',font=('楷体',16,"normal"),fg='#D8BC2E',justify=LEFT).place(x=700,y=445)
,text='⽇常⼯作',uo,font=("⿊体",16,"normal"),background='#D2FCFB',activebackground='#1AD8E8')\        .place(x=40,y=10,width=160,height=130)
,text='资料维护',command=self.ziliao,font=("⿊体",16,"normal"),background='#DAF4E6',activebackground='#1AD8E8')\
.place(x=200,y=140,width=160,height=130)
,text='历史查询',command=self.lishi,font=("⿊体",16,"normal"),background='#E2EFD3',activebackground='#1AD8E8')\
.place(x=360,y=270,width=160,height=130)
,text='系统管理',command=self.xitong,font=("⿊体",16,"normal"),background='#F0E4B2',activebackground='#1AD8E8')\
.place(x=520,y=400,width=160,height=130)
,text='安全退出',command=self.tuichu,font=("⿊体",16,"normal"),background='#7EE8A7',activebackground='#1AD8E8')\
.place(x=680,y=530,width=160,height=130)
def gongzuo(self):
Main01_ye()
def ziliao(self):
Main02_ye()
def lishi(self):
Main03_ye()
def xitong(self):
Main04_ye()
def tuichu(self):
class Main01_ye(object):#⽇常⼯作
def __init__(self):
< = Tk()
sw = winfo_screenwidth()#屏幕宽度
sh = winfo_screenheight()#屏幕⾼度
image = Image.open(r'./image/ffff.jpg')
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
background_label = , image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.guanli()
def guanli(self):
self.ts_jieyue = Ts_)
self.ts_guihuan = Ts_)
self.ts_fanjin = Ts_)
self.ts_xiaoshou = Ts_)
self.ts_chongzhi = Ts_)
self.ts_guanyu = Ts_)
self.ts_fanhui = Ts_)
self.ts_jieyue.pack()#默认显⽰
menubar = ,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_comman
d(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)
<['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_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()
Ye_mian()
class Main02_ye(object):#资料维护
def __init__(self):
< = Tk()
sw = winfo_screenwidth()#屏幕宽度
sh = 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
background_label = , image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.guanli()
def guanli(self):
self.ts_caigou = Ts_)
self.ts_baosun = Ts_)
self.ts_duzhe = Ts_)
self.ts_guanyu = Ts_)
self.ts_fanhui = Ts_)
self.ts_caigou.pack()#默认显⽰
menubar = ,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)        ['menu'] = menubar#设置菜单
def CG_data(self):

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。