大家好,给大家分享一下python算法和java算法的区别,很多人还不知道这一点。下面详细解释一下。现在让我们来看看!
文章目录
前言 二、建立数据库library 2.1 book表 2.2 borrow表 2.3 user表 三、各个模块介绍 3.1 初始界面initial 3.2 manager登录注册模块 3.3 ID模块 3.4 reader登录注册模块 3.5 m_operation管理员操作界面 3.6 r_operation读者操作模块 3.7 search模块(动态查询) 四、总结
前言
作者注:这是一个稚嫩青涩的项目,由于赶时间且自身技术不成熟,所以仅实现了基础功能且只能本地化运行,因此比较低端。
大三上学期的程序设计实训大作业,挑了其中一个我认为最简单的的《图书管理系统》来写。用python写是因为py有自带的GUI,即tkinter模块,对初次接触GUI的新手会比较友好。编译器我用的是Pycharm,你需要检查你的编译器是否带了tkinter模块和pymysql模块,没有的话需要下载安装,具体方法可以百度,很简单。界面很丑,凑合看哦!如果你没有了解过tkinter,建议先去知乎,csdn上面搜索自学一下入门教程,这样就比较容易理解我的东西啦! ** 特别注意:数据库表是我后来根据记忆建的,可能跟代码中的SQL语句的顺序有出入,实际数据库的字段值属性值顺序按照代码里的为准,修改一下数据库就好啦!代码是没问题的o( ̄︶ ̄)o **
二、建立数据库library
** 特别注意:这个表是我后来根据记忆建的,可能跟代码中的SQL语句的顺序有出入,实际数据库的字段值属性值顺序按照代码里的为准,修改一下数据库就好啦!代码是没问题的o( ̄︶ ̄)o ** 如图所示,软件是Navicat,给library建表。
2.1 book表
存储图书的相关信息,包括书名,作者,类型,数量。主码是name和author。
2.2 borrow表
借书单,存储借书人ID,书名,作者,借书时间。主码是name和author。
2.3 user表
使用者,包括ID,password,job是个只有1位的数字,0表示读者,1表示管理员,登录的时候通过检测其job然后选择是跳转到读者界面还是管理员界面。
三、各个模块介绍
3.1 初始界面initial
import tkinter as tk
import reader
import manager
def frame():#初始界面
global root
()
root.geometry('900x700')
root.title('西电图书管理系统')
lable0=tk.Label(root,text='欢迎来到XDU图书馆',bg='pink',font=('微软雅黑',50)).pack()#上
#canvas是个画布,想要插入图片的话首先要定义个canvas
canvas=tk.Canvas(root,height=500,width=500)#中
image_file=tk.PhotoImage(file='2.gif')
#图片文件的后缀必须是.gif,且亲测不能自行鼠标右键重命名更改成.gif,要用win10里内置的画图功能,打开图片然后另存为的时候选择.gif
#图片文件必须放到你的项目目录里边才有效
image=canvas.create_image(250,100,image=image_file)
canvas.place(x=170,y=170)
lable1=tk.Label(root,text='请选择用户类型:',font=('微软雅黑',20)).place(x=80,y=500)#下
tk.Button(root, text='读 者',font=('微软雅黑',15),width=10, height=2,command=exit_reader).place(x=350, y=420)
tk.Button(root, text='管理员',font=('微软雅黑',15),width=10, height=2,command=exit_manager).place(x=350, y=550)
root.mainloop()#必须要有这句话,你的页面才会动态刷新循环,否则页面不会显示
def exit_reader():#跳转至读者界面
root.destroy()
reader.frame()
def exit_manager():#跳转至管理员界面
root.destroy()
manager.frame()
if __name__ == '__main__':
frame()
效果就是上面这样的。 这个初始界面就比较简单,点击读者跳转到读者界面,点击管理员跳转到管理员界面。
3.2 manager登录注册模块
当我们从初始界面选择“管理员”,那么这时候调用exit_manager()函数,来到了管理员界面
import tkinter as tk
import tkinter.messagebox as msg #这个是会弹出一个警告/提示小框
import initial
import pymysql
import ID
def frame():#管理员界面
global root
root= ()
root.geometry('900x700')
root.title('西电图书管理系统')
lable0 = tk.Label(root, text='管理员登录', bg='pink', font=('微软雅黑', 50)).pack() # 上
canvas = tk.Canvas(root, height=500, width=500) # 中
image_file = tk.PhotoImage(file='2.gif')
image = canvas.create_image(250, 100, image=image_file)
canvas.place(x=190, y=170)
lable1 = tk.Label(root, text='请选择:', font=('微软雅黑', 20)).place(x=80, y=400) # 下
tk.Button(root, text='登录', font=('微软雅黑', 15), width=10, height=2, command=login).place(x=150, y=500)
tk.Button(root, text='注册', font=('微软雅黑', 15), width=10, height=2, command=register).place(x=350, y=500)
tk.Button(root, text='退出', font=('微软雅黑', 15), width=10, height=2, command=exit_manager).place(x=550, y=500)
root.mainloop()
def login():#登录小窗口
global root1
()
root1.wm_attributes('-topmost', 1)#将登录窗口置顶不至于被遮到下面
root1.title('管理员登录')
root1.geometry('500x300')
lable1 = tk.Label(root1, text='账号:', font=25).place(x=100,y=50)
lable2 = tk.Label(root1, text='密码:',