0% found this document useful (0 votes)
44 views11 pages

Final Word

This document contains the code for a library management system using Python and Tkinter. It defines classes and methods to create a graphical user interface (GUI) for library administrators and users. The GUI allows administrators to add, view, and manage book and student records stored in a MySQL database. Users can search for available books and check them out through the GUI. The code connects to the database to insert, update, and retrieve records as needed throughout the various methods.

Uploaded by

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

Final Word

This document contains the code for a library management system using Python and Tkinter. It defines classes and methods to create a graphical user interface (GUI) for library administrators and users. The GUI allows administrators to add, view, and manage book and student records stored in a MySQL database. Users can search for available books and check them out through the GUI. The code connects to the database to insert, update, and retrieve records as needed throughout the various methods.

Uploaded by

Rahul Bhurani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Programming

from tkinter import *

import tkinter.messagebox as msg

class Multiple():

def __init__(self,root):

self.root=root

self.root.geometry("400x400")

self.root.title("LMS")

self.root.config(bg="black")

label_1=Label(self.root,text="WELCOME",font=("Lucida
Calligraphy",20),bg="black",fg="powder blue").pack()

label_2=Label(self.root,text="TO",font=("Lucida
Calligraphy",20),bg="black",fg="red").pack()

label_3=Label(self.root,text="LIBRARY",font=("Lucida
Calligraphy",20),bg="black",fg="green").pack()

label_4=Label(self.root,text="MANAGEMENT",font=("Lucida
Calligraphy",20),bg="black",fg="pink").pack()

label_5=Label(self.root,text="SYSTEM",font=("Lucida
Calligraphy",20),bg="black",fg="orange").pack()

admin_button=Button(self.root,text="Entry",command=self.nextpage)

admin_button.place(x=180,y=280)

admin=Button(self.root,text="Exit",command=self.root.destroy)

admin.place(x=180,y=330)

def nextpage(self):

15
self.window=Tk()

self.window.geometry("300x300")

self.window.config(bg="pink")

self.a=Label(self.window,text="Username",bg="green",font=("itallic",15))

self.a.place(x=20,y=40)

self.b=Label(self.window,text="Password",bg="green",font=("itallic",15))

self.b.place(x=20,y=80)

self.u_entry=Entry(self.window)

self.u_entry.place(x=120,y=40)

self.p_entry=Entry(self.window)

self.p_entry.place(x=120,y=80)

s=Button(self.window,text="Home Page",command=self.man)

s.place(x=120,y=190)

n=Button(self.window,text="Manage
Students",bd="10",bg="red",font=("Times",10),anchor=CENTER,command=self.bb)

n.place(x=100,y=210)

l=Button(self.window,text="Manage
Books",bd="5",bg="cyan",font=("Times",10),anchor=CENTER,command=self.bbbbb)

l.place(x=110,y=250)

o=Button(self.window,text="Submit",command=self.nn)

o.place(x=120,y=150)

def nn(self):

import mysql.connector

16
mydb=mysql.connector.connect(host="localhost",user="root",password="mansi@1234",datab
ase="library")

my=mydb.cursor()

hh=self.u_entry.get()

ii=self.p_entry.get()

my.execute("insert into password values(%s,%s)",(hh,ii))

mydb.commit()

msg.showinfo("username password","Submitted")

def man(self):

man=Tk()

man.geometry("400x400")

man.title("Library Management System")

man.config(bg="navyblue")

title=Label(man,text='Home Page',bg="yellow",font=("Bold","34"),fg="Blue")

title.pack()

admin_button=Button(man,text="Admin",bg="Red",font=("Bold","20"),command=self.admin_p
age)

admin_button.place(x=150,y=120)

17
user_button=Button(man,text="User",font=("Bold","20"),bg="Red",command=self.user_page)

user_button.place(x=150,y=200)

def admin_page(self):

window=Tk()

window.title("Admin Page")

window.geometry("300x300")

window.config(bg="Yellow")

book_name_label=Label(window,text="Book
Name:",bg="powderblue",font=("Bold","20"))

book_name_label.place(x=20,y=40)

author_label=Label(window,text="Author Name:",bg="powderblue",font=("Bold","20"))

author_label.place(x=20,y=100)

qty_label=Label(window,text="Quantity:",bg="powderblue",font=("Bold","20"))

qty_label.place(x=20,y=160)

self.book_entry=Entry(window)

self.book_entry.place(x=200,y=40)

self.author_entry=Entry(window)

self.author_entry.place(x=200,y=100)

self.qty_entry=Entry(window)

18
self.qty_entry.place(x=150,y=160)

admin_submit=Button(window,text="Submit",command=self.admin_add)

admin_submit.place(x=120,y=250)

def user_page(self):

window1=Tk()

window1.title("User Page")

window1.geometry("300x300")

window1.config(bg="brown")

user_book_label=Label(window1,text="Book Name:",bg="green",font=("Bold","15"))

user_book_label.place(x=20,y=40)

user_author_label=Label(window1,text="Author:",bg="green",font=("Bold","15"))

user_author_label.place(x=20,y=150)

self.user_book_entry=Entry(window1)

self.user_book_entry.place(x=150,y=40)

self.author_book_entry=Entry(window1)

self.author_book_entry.place(x=150,y=150)

user_submit=Button(window1,text="Submit",bg="orange",command=self.user_data)

user_submit.place(x=130,y=200)

def bb(self):

v1=Tk()

v1.geometry("300x300")

19
v1.config(bg="purple")

ssfd=Label(v1,text="manage students",bg="olivedrab1",fg="black",font=("arial",16,"bold"))

ssfd.place(x=1,y=1)

aa=Label(v1,text="studentname",bg="light blue",fg="maroon",font=("itallic",16,"bold"))

aa.place(x=20,y=40)

bb4=Label(v1,text="Class",bg="light blue",fg="maroon",font=("arial",16,"bold"))

bb4.place(x=20,y=80)

cc=Label(v1,text="bookissued",bg="light blue",fg="maroon",font=("arial",16,"bold"))

cc.place(x=20,y=120)

dd=Label(v1,text="book",bg="light blue",fg="maroon",font=("arial",16,"bold"))

dd.place(x=20,y=160)

ee=Label(v1,text="bookreturned",bg="light blue",fg="maroon",font=("arial",16,"bold"))

ee.place(x=20,y=200)

self.aa1=Entry(v1)

self.aa1.place(x=190,y=40)

self.bb1=Entry(v1)

self.bb1.place(x=190,y=80)

self.cc1=Entry(v1)

self.cc1.place(x=190,y=120)

self.dd1=Entry(v1)

self. dd1.place(x=190,y=160)

self.ee1=Entry(v1)

self.ee1.place(x=190,y=200)

20
self.bbb=Button(v1,text="OK",command=self.bbbb)

self.bbb.place(x=100,y=250)

def bbbb(self):

import mysql.connector

mydb=mysql.connector.connect(host="localhost",user="root",password="mansi@1234",datab
ase="library")

my=mydb.cursor()

one=self.aa1.get()

two=self.bb1.get()

three=self.cc1.get()

four=self.dd1.get()

five=self.ee1.get()

my.execute("insert into studentrecord values(%s,%s,%s,%s,%s)",(one,two,three,four,five))

mydb.commit()

msg.showinfo("Student books","Detailed recorded")

def bbbbb(self):

v2=Tk()

v2.geometry("300x300")

v2.config(bg="orange")

21
sfd=Label(v2,text="M A N A G E B O O K
S",bg="olivedrab1",fg="black",font=("ariel",16,"bold"))

sfd.place(x=1,y=1)

x=Label(v2,text="book name",bg="light blue",fg="maroon",font=("ariel",16,"bold"))

x.place(x=20,y=40)

y=Label(v2,text="book id",bg="light blue",fg="maroon",font=("ariel",16,"bold"))

y.place(x=20,y=80)

z=Label(v2,text="author name",bg="light blue",fg="maroon",font=("ariel",16,"bold"))

z.place(x=20,y=120)

w=Label(v2,text="book cost",bg="light blue",fg="maroon",font=("ariel",16,"bold"))

w.place(x=20,y=160)

u=Label(v2,text="book pages",bg="light blue",fg="maroon",font=("ariel",16,"bold"))

u.place(x=20,y=200)

v=Label(v2,text="Book returned:",bg="light blue",fg="maroon",font=("itallic",16,"bold"))

v.place(x=20,y=240)

self.xx=Entry(v2)

self.xx.place(x=190,y=40)

self.yy=Entry(v2)

self.yy.place(x=190,y=80)

self.zz=Entry(v2)

self.zz.place(x=190,y=120)

self.ww=Entry(v2)

self.ww.place(x=190,y=160)

self.uu=Entry(v2)

22
self.uu.place(x=190,y=200)

self.vv=Entry(v2)

self.vv.place(x=190,y=240)

cc=Button(v2,text="OK",command=self.bbbbbb)

cc.place(x=150,y=280)

def bbbbbb(self):

import mysql.connector

mydb=mysql.connector.connect(host="localhost",user="root",password="mansi@1234",datab
ase="library")

my=mydb.cursor()

six=self.xx.get()

seven=self.yy.get()

eight=self.zz.get()

nine=self.ww.get()

ten=self.uu.get()

ele=self.vv.get()

my.execute("insert into bookrecord values(%s,%s,%s,%s,%s,%s)",


(six,seven,eight,nine,ten,ele))

mydb.commit()

msg.showinfo("books","Detailed recorded")

23
mansi=Button(root,text="Exit",command=root.destroy,bd="20",bg="green")

mansi.pack()

def admin_add(self):

import mysql.connector

mydb=mysql.connector.connect(host="localhost",user="root",password="mansi@1234",datab
ase="library")

mycursor=mydb.cursor()

bookname=self.book_entry.get()

author=self.author_entry.get()

qty=self.qty_entry.get()

mycursor.execute("insert into admin values(%s,%s,%s)",(bookname,author,qty))

mydb.commit()

msg.showinfo("Admin Books","Books added to stock")

def user_data(self):

import mysql.connector

mydb=mysql.connector.connect(host="localhost",user="root",password="mansi@1234",datab
ase="library")

mycursor=mydb.cursor()

book_name=self.user_book_entry.get()

24
author=self.author_book_entry.get()

mycursor.execute("select quantity from admin where book_name=%s and author=%s",


(book_name,author))

q=0

for i in mycursor:

q=int(i[0])

if q>=1:

q=q-1

mycursor.execute("update admin set quantity=%s where book_name=%s and author=


%s",(q,book_name,author))

mycursor.execute("insert into user values(%s,%s)",(book_name,author))

mydb.commit()

msg.showinfo("Book Availablity","Book Available")

else:

msg.showerror("Book Availability","Book not found")

root=Tk()

obj=Multiple(root)

root.mainloop()

25

You might also like