图书馆管理系统Python+MySQL+tkinter图形化界⾯+管理员登录+学⽣登录(注
释详细)
MySQL数据库模块
-- MySQL dump 10.13 Distrib 8.0.18, for Win64 (x86_64)
--
-- Host: localhost Database: library
-- ------------------------------------------------------
-- Server version 8.0.18
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
python教材下载/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/
*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `admin_login_k`
--
LOCK TABLES`admin_login_k`WRITE;
/*!40000 ALTER TABLE `admin_login_k` DISABLE KEYS */;
INSERT INTO`admin_login_k`VALUES('123','123');
/*!40000 ALTER TABLE `admin_login_k` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `book_k`
--
LOCK TABLES`book_k`WRITE;
/*!40000 ALTER TABLE `book_k` DISABLE KEYS */;
INSERT INTO`book_k`VALUES('1001','《python》','于孟林',11);
/
*!40000 ALTER TABLE `book_k` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `stu_k`
--
LOCK TABLES`stu_k`WRITE;
/*!40000 ALTER TABLE `stu_k` DISABLE KEYS */;
INSERT INTO`stu_k`VALUES('123','于孟林','123',0),('124','刘海','******',10);
/*!40000 ALTER TABLE `stu_k` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/
*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-12-20 22:15:38
Python源代码模块
import pymysql
from tkinter import ttk
import tkinter as tk
import tkinter.font as tkFont
from tkinter import*
ssagebox as messagebox
class StartPage:
def__init__(self, parent_window):
parent_window.destroy()
binary data官方下载self.window = Tk()
self.window.title('图书馆管理系统')
ry('450x450')
figure(bg ="SkyBlue")
label = Label(self.window, text="欢迎使⽤图书馆管理系统",font=("Verdana",22),bg='LightSeaGreen')
label.pack(pady=50)
Button(self.window, text="管理员登陆", font=tkFont.Font(size=16), command=lambda: Adminpage(self.window), width=30,
height=2,
fg='white', bg='green', activebackground='black', activeforeground='white').pack()
Button(self.window,text='学⽣登陆',font=tkFont.Font(size=16),command=lambda:StudentPage(self.window),width=30,
height=2,
fg='white',bg='green',activebackground='black', activeforeground='white').pack()
Button(self.window,text='使⽤说明',font=tkFont.Font(size=16),command=lambda:AboutPage(self.window),width=30,
height=2,
nasa火箭发射fg='white',bg='green',activebackground='black', activeforeground='white').pack()
self.window.mainloop()
class AboutPage:
def__init__(self, parent_window):
parent_window.destroy()
self.window = tk.Tk()# 初始框的声明
self.window.title('使⽤说明')
ry('450x450')# 这⾥的乘是⼩x
figure(bg ="SkyBlue")
label = tk.Label(self.window, text='图书馆管理系统使⽤说明', bg='green', font=('Verdana',20), width=30, height=2)
label.pack()
Label(self.window, text='1.系统⽤户由学⽣和管理员组成,\n学⽣账号并不是注册的⽽是管理员\n添加。管理员只有⼀个初始账号和\n密码均为123.', font= ('Verdana',18)).pack(pady=30)
Label(self.window, text='2.系统初步实现了借书还书,图书\n管理(管理员),学⽣管理功能.', font=('Verdana',18)).pack(padx=1,pady=5)
Label(self.window, text='3.待开发功能为获取借书,还书时\n间等详细记录.', font=('Verdana',18)).pack(padx=1,pady=5)
Label(self.window, text='4.系统使⽤Mysql数据库进⾏开发', font=('Verdana',18)).pack(padx=1, pady=5)
Button(self.window, text="返回⾸页", width=8, font=tkFont.Font(size=12), command=self.back).pack(padx=1,pady=100)
self.window.protocol("WM_DELETE_WINDOW", self.back)# 捕捉右上⾓关闭点击
class Adminpage:# ⼀个类⾥千万不要定义两个⼀样的⽅法呀!
def__init__(self, parent_window):
parent_window.destroy()
print('执⾏到Adminpage的第⼀个⽅法了')
self.window = tk.Tk()
self.window.title('管理员登陆页⾯')
ry('450x450')
figure(bg ="SkyBlue")
label = tk.Label(self.window, text='管理员登陆', bg='green', font=('Verdana',20), width=30, height=2)
label.pack()
Label(self.window, text='管理员账号: ', font=tkFont.Font(size=14)).pack(pady=25)
self.admin_id = tk.Entry(self.window, width=30, font=tkFont.Font(size=14), bg='Ivory')
self.admin_id.pack()
self.admin_id.pack()
brpc和grpcLabel(self.window, text='管理员密码: ', font=tkFont.Font(size=14)).pack(pady=25)
self.admin_pass = tk.Entry(self.window,show='*',width=30, font=tkFont.Font(size=14), bg='Ivory')
self.admin_pass.pack()
Button(self.window, text='登陆', width=8, font=tkFont.Font(size=12), command=self.login).pack(padx=30,pady=40)
Button(self.window, text='返回⾸页', width=8, font=tkFont.Font(size=12), command=self.back).pack(padx=30,pady=5)
self.window.protocol("WM_DELETE_WINDOW", self.back)
self.window.mainloop()
def login(self):
id=str(self.())
pas=str(self.())
print("执⾏到Adminage的login⽅法了")
print(id)
print('**')
print(pas)
db = t(host='localhost',
port=3306,
user='root',
passwd='YML852137',
charset='utf8'
)
cursor = db.cursor()
sql ="select * from admin_login_k"
results = cursor.fetchall()
for row in results:
print(row[0],' ', row[1])
f=0
for row in results:
if id== row[0]:
f=1
if pas == row[1]:
AdminManage(self.window)
else:
messagebox.showinfo("警告","密码错误!")
self.admin_pass.delete(0,END)
if f==0:
messagebox.showinfo("警告","⽤户名不存在")
self.admin_id.delete(0, END)用于表示数据库实体之间的关系图
self.admin_pass.delete(0, END)
db.close()
def back(self):
StartPage(self.window)# 回到主窗⼝
class AdminManage:
def__init__(self, parent_window):
parent_window.destroy()
self.window = Tk()
self.window.title('管理员操作界⾯')
figure(bg ="SkyBlue")
ry('450x450')
Button(self.window, text='学⽣管理', width=20,bg='green', font=tkFont.Font(size=30), command=self.Stu_Manage).grid(row=10, column=40,padx=30, pady=30)
pady=30)
Button(self.window, text='图书管理', width=20,bg='green', font=tkFont.Font(size=30), command=self.Book_Manage).grid(row=20,column=40,padx=30, pady=30)
Button(self.window, text='返回⾸页', width=20,bg='green', font=tkFont.Font(size=30), command=self.back).grid(row=30,column=40,padx=30, pady=30 )
def Stu_Manage(self):
self.frame_left_top = tk.Frame(width=300, height=200)
self.frame_right_top = tk.Frame(width=200, height=200)
self.frame_center = tk.Frame(width=500, height=400)
self.frame_bottom = tk.Frame(width=650, height=50)
< = ttk.Treeview(self.frame_center, show="headings", height=18, lumns)
self.vbar = ttk.Scrollbar(self.frame_center, orient=VERTICAL, view)
id(row=0, column=1, sticky=NS)
self.id=[]
self.name =[]
self.author =[]
db = t(host='localhost',
port=3306,
user='root',
passwd='YML852137',
charset='utf8'
)
cursor = db.cursor()
sql ="SELECT * FROM stu_k"
try:
results = cursor.fetchall()
for row in results:
self.id.append(row[0])
self.name.append(row[1])
self.author.append(row[2])
except:
print("Error: unable to fetch data")
messagebox.showinfo('警告!','数据库连接失败!')
db.close()
for i in range(min(len(self.id),len(self.name),len(self.author),unt))):# 写⼊数据
for col lumns:
command=lambda _col=col: _sort_, _col,False))
self.left_top_frame = tk.Frame(self.frame_left_top)
self.var_id = StringVar()
self.var_id = StringVar()
self.var_name = StringVar()
self.var_author = StringVar()
self.var_count = StringVar()
# 图书号
self.right_top_id_label = Label(self.frame_left_top, text="学号:", font=('Verdana',15))
self.right_top_id_entry = Entry(self.frame_left_top, textvariable=self.var_id, font=('Verdana',15))
self.right_top_id(row=1, column=0)
self.right_top_id(row=1, column=1)
# 书名
self.right_top_name_label = Label(self.frame_left_top, text="姓名:", font=('Verdana',15))
self.right_top_name_entry = Entry(self.frame_left_top, textvariable=self.var_name, font=('Verdana',15))
self.right_top_id(row=2, column=0)
self.right_top_id(row=2, column=1)
# 作者
self.right_top_gender_label = Label(self.frame_left_top, text="密码:", font=('Verdana',15))
self.right_top_gender_entry = Entry(self.frame_left_top,show='*', textvariable=self.var_author,
font=('Verdana',15))
self.right_top_id(row=3, column=0)
self.right_top_id(row=3, column=1)
# 数量
self.right_top_gender_label = Label(self.frame_left_top, text="借阅数量:", font=('Verdana',15))
self.right_top_gender_entry = Entry(self.frame_left_top, textvariable=self.var_count,
font=('Verdana',15))
self.right_top_id(row=4, column=0)
self.right_top_id(row=4, column=1)
# 定义右上⽅区域
self.right_top_title = Label(self.frame_right_top, text="操作:", font=('Verdana',20))
self.right_top_button1 = ttk.Button(self.frame_right_top, text='新建学⽣信息', width=20, w_row1) self.right_top_button2 = ttk.Button(self.frame_right_top, text='更新选中学⽣信息', width=20,
command=self.updata_row1)
self.right_top_button3 = ttk.Button(self.frame_right_top, text='删除选中学⽣信息', width=20,
command=self.del_row1)
self.right_id(row=1, column=0, pady=10)
self.right_id(row=2, column=0, padx=20, pady=10)
self.right_id(row=3, column=0, padx=20, pady=10)
self.right_id(row=4, column=0, padx=20, pady=10)
怎么制作网页文件self.frame_id(row=0, column=0, padx=2, pady=5)
self.frame_id(row=0, column=1, padx=30, pady=30)
self.id(row=1, column=0, columnspan=2, padx=4, pady=5)
self.id(row=2, column=0, columnspan=2)
self.frame_id_propagate(0)
self.frame_id_propagate(0)
self.id_propagate(0)
self.id_propagate(0)
self.frame_left_top.tkraise()
self.frame_right_top.tkraise()
self.frame_center.tkraise()
self.frame_bottom.tkraise()
self.window.protocol("WM_DELETE_WINDOW", self.back)
self.window.mainloop()
def click1(self, event):
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论