0% found this document useful (0 votes)
4 views9 pages

IP Project

This document outlines a library management system built using Python's Tkinter for the GUI and MySQL for the database. It includes functionalities for adding new books, borrowing books, returning books, searching for books, and displaying book details and statistics through graphs. The application features user authentication for administrative tasks and provides a user-friendly interface for managing library operations.

Uploaded by

amitdudii890
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views9 pages

IP Project

This document outlines a library management system built using Python's Tkinter for the GUI and MySQL for the database. It includes functionalities for adding new books, borrowing books, returning books, searching for books, and displaying book details and statistics through graphs. The application features user authentication for administrative tasks and provides a user-friendly interface for managing library operations.

Uploaded by

amitdudii890
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

from tkinter import *

from tkinter import font


from [Link] import showinfo
import [Link] as mysql
from PIL import ImageTk, Image
from tkinter import ttk
import [Link] as plt
import pandas as pd

admin = 'Admin'
password = '12345'

def quit():
[Link]()

def newBook():
def topUp_destroy():
top_up1.destroy()

def newBookSql():
try:
userName_entry.delete(0, END)
password_entry.delete(0, END)

value = (
[Link](),
[Link](),
[Link]()
)

[Link]("create table if not exists books (bookName


varchar(30), class varchar(5), edition varchar(5))")
[Link]("insert into books values(%s,%s,%s)", value)
[Link]()

[Link](0, END)
[Link](0, END)
[Link](0, END)

show_details()

except Exception as f:
showinfo('ERROR!!!', 'Something went wrong! Please try again
later')
top_up1.destroy()
print(f)

uservalue = userName_entry.get()
passvalue = password_entry.get()

if uservalue == admin and passvalue == password:

top_up1 = Toplevel()
top_up1.geometry('523x611+743+190')
top_up1.maxsize(523, 611)
top_up1.configure(bg='cyan')

frame1 = Frame(top_up1)
[Link]()

bookNameLabel = Label(top_up1, text=' BookName ', bg='cyan',


font='cosmic 19 bold')
bookClassLabel = Label(top_up1, text=' Class ', bg='cyan',
font='cosmic 14 bold')
bookEditionLabel = Label(top_up1, text=' Edition ', bg='cyan',
font='cosmic 18 bold')

[Link](x=87, y=66)
[Link](x=92, y=112)
[Link](x=89, y=159)

bookNameEntry = Entry(top_up1)
bookClassEntry = Entry(top_up1)
bookEditionEntry = Entry(top_up1)

[Link](y=68, x=221)
[Link](y=113, x=222)
[Link](y=157, x=221)

b1 = Button(top_up1, text=' Done ', relief=GROOVE, font='cosmic


16 bold', bg='cyan', command=newBookSql)
[Link](x=199, y=214)

b2 = Button(top_up1, text=' EXIT ', relief=GROOVE, font='cosmic


14 bold', bg='cyan', command=topUp_destroy)
[Link](x=199, y=266)

else:
showinfo('invalid', 'username or password invalid')

def borrow_book():
def end():
top_up2.destroy()

def borrowSql():
book_name = [Link]()
book_class = [Link]()
book_edition = [Link]()
value = ([Link](), [Link](), [Link](), [Link]())
temp = (book_name, book_class, book_edition)

try:
sql1 = '''create table IF NOT EXISTS borrower (borrower_name
varchar(25),
book_name varchar(30), edition varchar(10), class
varchar(7))'''
sql2 = """DELETE from books where bookName = %s AND edition
= %s"""

[Link]('select * from books')


data = [Link]()

if temp in data:
[Link](sql1)
[Link](sql2, (book_name, book_edition))
[Link]()

[Link]('insert into borrower


values(%s,%s,%s,%s)', value)
[Link]()

top_up2.destroy()
show_details()

showinfo('Congratulation', 'Hope you will like this book


return on time.')

else:
showinfo('Sorry ☹', 'Sorry book is not available')
top_up2.destroy()

except Exception as f:
showinfo('ERROR ', 'You got some error')
top_up2.destroy()
print(f)

top_up2 = Toplevel()
top_up2.geometry('455x590+12+8')
top_up2.configure(bg='maroon')
top_up2.maxsize(455, 590)

frame5 = Frame(top_up2)
[Link]()

l1 = Label(top_up2, text='Your Name', bg="maroon", fg='white',


font='cosmic 15 bold')
l2 = Label(top_up2, text='Book Name', bg="maroon", fg='white',
font='cosmic 16 bold')
l3 = Label(top_up2, text='Edition', bg="maroon", fg='white',
font='cosmic 17 bold')
l4 = Label(top_up2, text='Class', bg="maroon", fg='white',
font='cosmic 14 bold')

[Link](x=39, y=67)
[Link](x=41, y=119)
[Link](x=41, y=171)
[Link](x=42, y=226)

global e1Var, e2Var, e3Var, e4Var


e1Var = StringVar()
e2Var = StringVar()
e3Var = StringVar()
e4Var = StringVar()

e1 = Entry(top_up2, textvariable=e1Var)
e2 = Entry(top_up2, textvariable=e2Var)
e3 = Entry(top_up2, textvariable=e3Var)
e4 = Entry(top_up2, textvariable=e4Var)

[Link](x=212, y=67)
[Link](x=213, y=118)
[Link](x=213, y=169)
[Link](x=213, y=224)

b1 = Button(top_up2, text=' Borrow ', bg='maroon', relief=RAISED,


font='cosmic 16 bold', command=borrowSql)
b2 = Button(top_up2, text=' Exit ', bg='maroon', relief=RAISED,
font='cosmic 15 bold', command=end)

[Link](x=77, y=280)
[Link](x=257, y=280)

def return_book():
def end():
top_up3.destroy()

def returnSql():
try:
b_name = [Link]()
name = [Link]()
b_edition = [Link]()
values = (b_name, name, b_edition)

sql = '''DELETE from borrower where borrower_name = %s


AND book_name = %s
AND edition = %s'''

[Link](sql, values)
[Link]()

value = ([Link](), [Link](), [Link]())

[Link]('insert into books values(%s,%s,%s)', value)


[Link]()

top_up3.destroy()

except Exception as f:
showinfo('ERROR ', 'Something went wrong')
top_up3.destroy()
print(f)

top_up3 = Toplevel()
top_up3.geometry('344x477')
top_up3.configure(bg='lightblue1')

l1 = Label(top_up3, text='Your Name', font='cosmic 14 bold',


bg='lightblue1')
label2 = Label(top_up3, text='Book Name', font='cosmic 16 bold',
bg='lightblue1')
label3 = Label(top_up3, text='Book Edition', font='cosmic 18 bold',
bg='lightblue1')
label4 = Label(top_up3, text='Class', font='cosmic 15 bold',
bg='lightblue1')

[Link](x=38, y=61)
[Link](x=38, y=112)
[Link](x=38, y=165)
[Link](x=38, y=219)

entry1 = Entry(top_up3)
entry2 = Entry(top_up3)
entry3 = Entry(top_up3)
entry4 = Entry(top_up3)

[Link](x=172, y=60)
[Link](x=172, y=111)
[Link](x=172, y=164)
[Link](x=172, y=220)

b1 = Button(top_up3, text=' Done ', bg='lightblue1', relief=RAISED,


command=returnSql)
b2 = Button(top_up3, text=' Exit ', bg='lightblue1', relief=RAISED,
command=end)

[Link](x=61, y=274)
[Link](x=212, y=274)

def dataOnClick(ev):
try:
selectedRow = [Link]()
rowData = [Link](selectedRow)
data = rowData['values']

[Link](data[0])
[Link](data[1])
[Link](data[2])

except Exception as f:
print(f)

def show_details():
try:
db = [Link](host="localhost", user="root", password="",
database="library")
worker = [Link]()

[Link]('select * from books')


fetchData = [Link]()

if len(fetchData) != 0:
for item in bookDetails.get_children():
[Link](item)
for f in fetchData:
[Link]('', END, values=f)
[Link]()

except Exception as e:
print(e)

def showCondition_details():
try:
db = [Link](host="localhost", user="root", password="",
database="library")
worker = [Link]()

[Link]("select * from books where " + str([Link]())


+ " LIKE '%" + str([Link]()) + "%'")
fetchData = [Link]()

if len(fetchData) != 0:
for item in bookDetails.get_children():
[Link](item)
for f in fetchData:
[Link]('', END, values=f)

[Link]()

except Exception:
pass

def showGraph():
db = [Link](host="localhost", user="root", password="",
database="library")
worker = [Link]()

list1 = []
for f in range(1, 13):
[Link]('select count(class) from books where class =' +
str(f))
data = [Link]()
[Link](data)

list2 = []
for var1 in list1:
for var2 in var1:
for var3 in var2:
[Link](var3)

labels = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th',


'9th', '10th', '11th', '12th']
[Link](labels, list2, width=0.6)
[Link]('NO. Of Books')
[Link]('Classes')
[Link]('Class wise no. of books')
[Link]()

faru = Tk()
width = faru.winfo_screenwidth()
height = faru.winfo_screenheight()
[Link]("%dx%d" % (width, height))
[Link](bg='cyan')
[Link]('LIBRARY MANAGEMENT')

searchBy = StringVar()
searchText = StringVar()

label1 = Label(faru, text="DMS LIBRARY", font=('times new roman', 39,


'bold'), bg='red', fg='black')
[Link](side=TOP, anchor='n', fill=X)

frame1 = Frame(faru, bg='skyblue', borderwidth=6, relief=FLAT,


height=556)
[Link](x=24, y=92, width=355, height=566)

frame2 = Frame(faru, bg='skyblue', borderwidth=6, relief=FLAT,


height=566)
[Link](x=402, y=92, width=574, height=566)

frame3 = Frame(faru, bg='skyblue', borderwidth=6, relief=FLAT,


height=566)
[Link](x=1002, y=92, width=314, height=566)

show_button = Button(frame1, bg='azure', fg='black', text=' SHOW BOOK ',


font=('', 16, 'bold'), relief=RAISED, width=17)
borrow_button = Button(frame1, bg='azure', fg='black', text=' ISSUE BOOK
', font=('', 17, 'bold'), relief=RAISED, width=17, command=borrow_book)
return_button = Button(frame1, bg='azure', fg='black', text=' RETURN BOOK
', font=('', 14, 'bold'), relief=RAISED, width=17, command=return_book)
graph_button = Button(frame1, bg='azure', fg='black', text=' SHOW GRAPH
', font=('', 18, 'bold'), relief=RAISED, width=17, command=showGraph)
exit_button = Button(frame1, bg='azure', fg='black', text=' EXIT ',
font=('', 14), relief=RAISED, width=13, command=quit)

show_button.place(x=71, y=22)
borrow_button.place(x=70, y=108)
return_button.place(x=70, y=195)
graph_button.place(x=70, y=281)
exit_button.place(x=107, y=365)

newBook_label = Label(frame3, text='For Adding Book', font=('', 20,


'bold'), bg='skyblue')
newBook_label.pack(side=TOP, fill=X, pady=11)
userName_label = Label(frame3, text='Username: ', font=('', 15),
bg="skyblue")
password_label = Label(frame3, text='Password: ', font=('', 14),
bg="skyblue")

userName_label.place(x=17, y=62)
password_label.place(x=17, y=94)

userName_entry = Entry(frame3)
password_entry = Entry(frame3, show='*')

userName_entry.place(x=132, y=62)
password_entry.place(x=132, y=95)

button1 = Button(frame3, text='DONE', font=('', 13, 'bold'),


command=newBook)
[Link](x=132, y=155)

try:
bg = [Link]([Link]("[Link]"))
canvas1 = Canvas(frame3, width=244, height=245)
[Link](side=LEFT, anchor='sw', expand=True, padx=38, pady=38)
canvas1.create_image(122, 6, image=bg, anchor="n")
except:
pass

labelSearch = Label(frame2, text="Search By:", bg="skyblue", fg="black",


font=("times new roman", 16, "bold"))
[Link](row=0, column=0, pady=11, padx=11, sticky="w")

comboSearch = [Link](frame2, textvariable=searchBy, font=("times


new roman", 14, "bold"), state='readonly', width=11)
comboSearch['values'] = ("bookName", "Class", "Edition")
[Link](row=0, column=1, padx=0, pady=11)

txt_Search = Entry(frame2, textvariable=searchText, font=("times new


roman", 15, "bold"), bd=3, relief=GROOVE, width=11)
txt_Search.grid(row=0, column=2, pady=11, padx=11, sticky="w")

searchButton = Button(frame2, text="Search", width=11,


command=showCondition_details)
[Link](row=0, column=3, padx=11, pady=11)

showAllButton = Button(frame2, text="Show All", width=11,


command=show_details)
[Link](row=0, column=4, padx=11, pady=11)

frame4 = Frame(frame2, bd=4, relief=RIDGE, bg="white")


[Link](x=15, y=56, width=547, height=512)

yAxis = Scrollbar(frame4, orient=VERTICAL)


bookDetails = [Link](frame4, columns=('bookName', 'class',
'edition'), yscrollcommand=[Link])
[Link](side=RIGHT, fill=Y)
[Link](command=[Link])

[Link]('bookName', text='Book Name')


[Link]('class', text='Class')
[Link]('edition', text='Edition')
bookDetails['show'] = 'headings'

[Link]('bookName', width=293)
[Link]('class', width=127)
[Link]('edition', width=129)

[Link]('<ButtonRelease-1>', dataOnClick)
[Link](fill=BOTH, expand=1)

show_details()

try:
db = [Link](host="localhost", user="root", password="",
database="library")
worker = [Link]()
except:
showinfo('ERROR ', 'Please start your mysql local server ')
exit()

[Link]()

You might also like