├── .gitignore ├── db └── lms.db ├── full_logo.jpg ├── new_logo.png ├── requirements.txt ├── __pycache__ ├── AddBook.cpython-311.pyc ├── AddBook.cpython-39.pyc ├── EditBook.cpython-39.pyc ├── database.cpython-39.pyc ├── BookReport.cpython-311.pyc ├── BookReport.cpython-39.pyc ├── DeleteBook.cpython-311.pyc ├── DeleteBook.cpython-39.pyc ├── EditBook.cpython-311.pyc ├── IssueBook.cpython-311.pyc ├── IssueBook.cpython-39.pyc ├── ReturnBook.cpython-311.pyc ├── ReturnBook.cpython-39.pyc ├── ViewBooks.cpython-311.pyc ├── ViewBooks.cpython-39.pyc ├── database.cpython-311.pyc ├── Miscellaneous.cpython-39.pyc └── Miscellaneous.cpython-311.pyc ├── config └── settings.json ├── README.md ├── DeleteBook.py ├── BookReport.py ├── db.py ├── IssueBook.py ├── ReturnBook.py ├── AddBook.py ├── EditBook.py ├── Miscellaneous.py ├── database.py ├── ViewBooks.py └── main.py /.gitignore: -------------------------------------------------------------------------------- 1 | _pycache_/ 2 | token 3 | output -------------------------------------------------------------------------------- /db/lms.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/db/lms.db -------------------------------------------------------------------------------- /full_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/full_logo.jpg -------------------------------------------------------------------------------- /new_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/new_logo.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/requirements.txt -------------------------------------------------------------------------------- /__pycache__/AddBook.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/AddBook.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/AddBook.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/AddBook.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/EditBook.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/EditBook.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/database.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/database.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/BookReport.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/BookReport.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/BookReport.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/BookReport.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/DeleteBook.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/DeleteBook.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/DeleteBook.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/DeleteBook.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/EditBook.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/EditBook.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/IssueBook.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/IssueBook.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/IssueBook.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/IssueBook.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/ReturnBook.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/ReturnBook.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/ReturnBook.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/ReturnBook.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/ViewBooks.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/ViewBooks.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/ViewBooks.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/ViewBooks.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/database.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/database.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/Miscellaneous.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/Miscellaneous.cpython-39.pyc -------------------------------------------------------------------------------- /__pycache__/Miscellaneous.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bajrangCoder/LMS/HEAD/__pycache__/Miscellaneous.cpython-311.pyc -------------------------------------------------------------------------------- /config/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "theme": "Dark", 3 | "color_theme": "dark-blue", 4 | "charge_per_day": 5, 5 | "issue_duration": 1, 6 | "footer_txt": "Developed By Raunak Raj!" 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LMS 2 | Library management software built using python, tkinter, customtkinter 3 | 4 | > Note: Development is going on of LMS-Pro. LMS-Pro contains impressive ui, responsive, light-weight, blazingly-fast because it built on top of Rustlang. 5 | 6 | For downloading check release section. 7 | -------------------------------------------------------------------------------- /DeleteBook.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from database import LMS 4 | from tkinter.messagebox import showerror, showinfo 5 | import os 6 | import sys 7 | 8 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 9 | 10 | class DeleteBook(customtkinter.CTkToplevel): 11 | def __init__(self, master=None): 12 | super().__init__(master) 13 | self.title("Library Management System") 14 | self.minsize(400,250) 15 | self.maxsize(400,250) 16 | self.geometry('400x250') 17 | 18 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 19 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 20 | 21 | label = customtkinter.CTkLabel(master=heading_frame, text="Delete Book",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 22 | label.pack(ipady=10) 23 | 24 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 25 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 26 | 27 | book_id_lbel = customtkinter.CTkLabel(master=main_frame,text="Book ID", font=customtkinter.CTkFont(family="Verdana",size=18)) 28 | book_id_lbel.pack() 29 | 30 | self.book_id_input = customtkinter.CTkEntry(master=main_frame, width=200) 31 | self.book_id_input.pack(padx=5, pady=10) 32 | 33 | delete_book_btn = customtkinter.CTkButton(master=main_frame,text="Delete Book",command=self.delete_book) 34 | delete_book_btn.pack(padx=10,pady=10) 35 | 36 | def delete_book(self): 37 | id_lists = db.all_book_id() 38 | new_id_lists = [t[0] for t in id_lists] 39 | if int(self.book_id_input.get()) in new_id_lists: 40 | res = db.delete_book(self.book_id_input.get()) 41 | if res == 'deleted': 42 | showinfo(title="Deleted",message=f"Book ID : {self.book_id_input.get()}, deleted successfully.") 43 | self.book_id_input.delete(0,'end') 44 | else: 45 | showerror(title="Error",message=f"Book ID : {self.book_id_input.get()}, not deleted. Try Again!") 46 | else: 47 | showerror(title="Not Found",message="Book not found") -------------------------------------------------------------------------------- /BookReport.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from database import LMS 4 | from tkinter.messagebox import showerror, showinfo 5 | from tkinter import filedialog 6 | import pandas as pd 7 | import os 8 | import sys 9 | 10 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 11 | 12 | class BookReport(customtkinter.CTkToplevel): 13 | def __init__(self, master=None): 14 | super().__init__(master) 15 | self.title("Library Management System") 16 | self.minsize(400,300) 17 | self.maxsize(400,300) 18 | self.geometry('400x300') 19 | 20 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 21 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 22 | 23 | label = customtkinter.CTkLabel(master=heading_frame, text="Generate Book Report",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 24 | label.pack(ipady=10) 25 | 26 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 27 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 28 | 29 | avlb_book_export_btn = customtkinter.CTkButton(master=main_frame,text="Export Available Book",command=self.export_available_book) 30 | avlb_book_export_btn.pack(padx=10,pady=10) 31 | 32 | issue_book_exp_btn = customtkinter.CTkButton(master=main_frame,text="Export Issued Book",command=self.export_issued_book) 33 | issue_book_exp_btn.pack(padx=10,pady=10) 34 | 35 | export_all_book_btn = customtkinter.CTkButton(master=main_frame,text="Export All Book",command=self.export_all_book) 36 | export_all_book_btn.pack(padx=10,pady=10) 37 | 38 | export_fine_btn = customtkinter.CTkButton(master=main_frame,text="Export Fine Details",command=self.export_fine_detail) 39 | export_fine_btn.pack(padx=10,pady=10) 40 | 41 | def export_available_book(self): 42 | dbt = db.all_available_book() 43 | data = pd.read_sql_query(dbt[0],dbt[1]) 44 | try: 45 | selected_folder = filedialog.askdirectory() 46 | data.to_excel(f"{selected_folder}/available_books.xlsx") 47 | showinfo(title="Success",message="Exported successfully") 48 | except: 49 | showerror(title="Error", message="Location not selected...") 50 | 51 | def export_issued_book(self): 52 | dbt = db.all_issued_book() 53 | data = pd.read_sql_query(dbt[0],dbt[1]) 54 | try: 55 | selected_folder = filedialog.askdirectory() 56 | data.to_excel(f"{selected_folder}/issued_books.xlsx") 57 | showinfo(title="Success",message="Exported successfully") 58 | except: 59 | showerror(title="Error", message="Location not selected...") 60 | 61 | def export_all_book(self): 62 | dbt = db.all_books() 63 | data = pd.read_sql_query(dbt[0],dbt[1]) 64 | try: 65 | selected_folder = filedialog.askdirectory() 66 | data.to_excel(f"{selected_folder}/all_books.xlsx") 67 | showinfo(title="Success",message="Exported successfully") 68 | except: 69 | showerror(title="Error", message="Location not selected...") 70 | 71 | def export_fine_detail(self): 72 | dbt = db.fine_detail() 73 | data = pd.read_sql_query(dbt[0],dbt[1]) 74 | try: 75 | selected_folder = filedialog.askdirectory() 76 | data.to_excel(f"{selected_folder}/fine_details.xlsx") 77 | showinfo(title="Success",message="Exported successfully") 78 | except: 79 | showerror(title="Error", message="Location not selected...") -------------------------------------------------------------------------------- /db.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | from sqlite3 import Error 3 | 4 | 5 | def create_connection(db_file): 6 | """ create a database connection to the SQLite database 7 | specified by db_file 8 | :param db_file: database file 9 | :return: Connection object or None 10 | """ 11 | conn = None 12 | try: 13 | conn = sqlite3.connect(db_file) 14 | return conn 15 | except Error as e: 16 | print(e) 17 | 18 | return conn 19 | 20 | 21 | def create_table(conn, create_table_sql): 22 | """ create a table from the create_table_sql statement 23 | :param conn: Connection object 24 | :param create_table_sql: a CREATE TABLE statement 25 | :return: 26 | """ 27 | try: 28 | c = conn.cursor() 29 | c.execute(create_table_sql) 30 | except Error as e: 31 | print(e) 32 | 33 | 34 | def main(): 35 | database = "./lms.db" 36 | 37 | sql_create_projects_table = """ CREATE TABLE IF NOT EXISTS books ( 38 | book_id integer PRIMARY KEY, 39 | book_name text NOT NULL, 40 | book_author text, 41 | book_edition text, 42 | book_price text, 43 | date_of_purchase DATETIME, 44 | status text 45 | ); """ 46 | 47 | sql_create_tasks_table = """CREATE TABLE IF NOT EXISTS issued_book ( 48 | book_id integer, 49 | issued_to integer, 50 | issued_on DATETIME NOT NULL, 51 | expired_on DATETIME NOT NULL, 52 | is_miscellaneous integer DEFAULT 0 NOT NULL, 53 | FOREIGN KEY (book_id) 54 | REFERENCES books (book_id) 55 | ON UPDATE CASCADE 56 | ON DELETE CASCADE 57 | FOREIGN KEY (issued_to) 58 | REFERENCES student (id) 59 | ON UPDATE CASCADE 60 | ON DELETE CASCADE 61 | );""" 62 | 63 | sql_create_tasks1_table = """CREATE TABLE IF NOT EXISTS student ( 64 | id integer PRIMARY KEY, 65 | name integer NOT NULL, 66 | class text NOT NULL 67 | );""" 68 | 69 | sql_create_tasks2_table = """CREATE TABLE IF NOT EXISTS fine_details ( 70 | book_id integer, 71 | student_id integer, 72 | issued_on DATETIME NOT NULL, 73 | returned_date DATETIME NOT NULL, 74 | total_fine integer, 75 | no_of_day integer, 76 | FOREIGN KEY (book_id) 77 | REFERENCES books (book_id) 78 | ON UPDATE CASCADE 79 | ON DELETE CASCADE 80 | FOREIGN KEY (student_id) 81 | REFERENCES student (id) 82 | ON UPDATE CASCADE 83 | ON DELETE CASCADE 84 | );""" 85 | 86 | 87 | # create a database connection 88 | conn = create_connection(database) 89 | 90 | # create tables 91 | if conn is not None: 92 | # create projects table 93 | create_table(conn, sql_create_projects_table) 94 | 95 | # create tasks table 96 | create_table(conn, sql_create_tasks_table) 97 | create_table(conn, sql_create_tasks1_table) 98 | create_table(conn, sql_create_tasks2_table) 99 | else: 100 | print("Error! cannot create the database connection.") 101 | 102 | 103 | if __name__ == '__main__': 104 | main() -------------------------------------------------------------------------------- /IssueBook.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from database import LMS 4 | from tkinter.messagebox import showerror, showinfo 5 | from tkinter import ttk 6 | import datetime 7 | import json 8 | import os 9 | import sys 10 | 11 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 12 | 13 | settings_file_path = os.path.join(os.path.dirname(sys.executable), 'settings.json') 14 | with open(settings_file_path, "r") as settings_file: 15 | settings = json.load(settings_file) 16 | 17 | class IssueBook(customtkinter.CTkToplevel): 18 | def __init__(self, master=None): 19 | super().__init__(master) 20 | self.title("Library Management System") 21 | self.minsize(400,250) 22 | self.maxsize(400,250) 23 | self.geometry('300x250') 24 | self.no_expiry_days = settings["issue_duration"] 25 | 26 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 27 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 28 | 29 | self.label = customtkinter.CTkLabel(master=heading_frame, text="Issue Book",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 30 | self.label.pack(ipady=10) 31 | 32 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 33 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 34 | 35 | main_frame.columnconfigure(1, weight=1) 36 | main_frame.columnconfigure(2, weight=1) 37 | 38 | book_id_lbel = customtkinter.CTkLabel(master=main_frame,text="Book ID") 39 | book_id_lbel.grid(column=1,row=0,padx=5, pady=5) 40 | 41 | self.book_id_var = customtkinter.StringVar(self) 42 | self.book_id_input = customtkinter.CTkEntry(master=main_frame, width=200,textvariable=self.book_id_var) 43 | self.book_id_input.grid(column=2,row=0,padx=5, pady=10) 44 | 45 | student_id_lbel = customtkinter.CTkLabel(master=main_frame,text="Student ID") 46 | student_id_lbel.grid(column=1,row=1,padx=5, pady=5) 47 | self.student_id_var = customtkinter.StringVar(self) 48 | self.student_id_input = customtkinter.CTkEntry(master=main_frame, width=200, textvariable=self.student_id_var) 49 | self.student_id_input.grid(column=2,row=1,padx=5, pady=5) 50 | 51 | issue_book_btn = customtkinter.CTkButton(master=main_frame,text="Issue Book",command=self.issue_book) 52 | issue_book_btn.grid(column=2,row=2,padx=10,pady=5) 53 | 54 | def issue_book(self): 55 | book_id = self.book_id_var.get() 56 | book_id = int(book_id) 57 | student_id = self.student_id_var.get() 58 | student_id = int(student_id) 59 | 60 | if book_id in self.all_book_id() and student_id in self.all_student_id(): 61 | status = 'available' 62 | if status in db.select_book_status(book_id): 63 | cur_dt = datetime.datetime.now() 64 | std_cur_dt = cur_dt.isoformat(' ', 'seconds') 65 | data = ( 66 | book_id, 67 | student_id, 68 | std_cur_dt, 69 | self.expiry_datetime() 70 | ) 71 | 72 | res1 = db.issue_book(data) 73 | res2 = db.update_book_status(book_id,"issued") 74 | 75 | if res1 != None: 76 | showinfo(title="Issued",message=f"Book issued successfully to {student_id}") 77 | else: 78 | showerror(title="Error",message="Something went wrong! Try Again..") 79 | else: 80 | showerror(title="Not Available",message="This book is not available or it is issued to another one.") 81 | else: 82 | showerror(title="Not Found",message="Book not found! or Student Not found! Please Check Book ID or Student ID and try again...") 83 | 84 | def all_book_id(self): 85 | all_bookID = [] 86 | for i in db.all_book_id(): 87 | all_bookID.append(i[0]) 88 | return all_bookID 89 | 90 | def all_student_id(self): 91 | all_studentID = [] 92 | for i in db.all_student_id(): 93 | all_studentID.append(i[0]) 94 | return all_studentID 95 | 96 | def expiry_datetime(self): 97 | exp_datetime = datetime.datetime.now() 98 | exp_datetime += datetime.timedelta(days=self.no_expiry_days) 99 | std_exp_dt = exp_datetime.isoformat(' ', 'seconds') 100 | return std_exp_dt 101 | -------------------------------------------------------------------------------- /ReturnBook.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from database import LMS 4 | from tkinter.messagebox import showerror, showinfo, askyesno 5 | import datetime 6 | import json 7 | import os 8 | import sys 9 | 10 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 11 | 12 | settings_file_path = os.path.join(os.path.dirname(sys.executable), 'settings.json') 13 | with open(settings_file_path, "r") as settings_file: 14 | settings = json.load(settings_file) 15 | 16 | class ReturnBook(customtkinter.CTkToplevel): 17 | def __init__(self, master=None): 18 | super().__init__(master) 19 | self.title("Library Management System") 20 | self.minsize(400,250) 21 | self.maxsize(400,250) 22 | self.geometry('400x250') 23 | self.charge_per_day = settings["charge_per_day"] 24 | 25 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 26 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 27 | 28 | label = customtkinter.CTkLabel(master=heading_frame, text="Return Book",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 29 | label.pack(ipady=10) 30 | 31 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 32 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 33 | 34 | book_id_lbel = customtkinter.CTkLabel(master=main_frame,text="Book ID",font=customtkinter.CTkFont(family="Verdana",size=16, weight="normal")) 35 | book_id_lbel.pack(pady=10) 36 | 37 | self.book_id_var = customtkinter.StringVar(self) 38 | self.book_id_input = customtkinter.CTkEntry(master=main_frame, width=200, textvariable=self.book_id_var) 39 | self.book_id_input.pack(padx=5, pady=5) 40 | 41 | return_book_btn = customtkinter.CTkButton(master=main_frame,text="Return Book",command=self.return_book) 42 | return_book_btn.pack(padx=10,pady=5) 43 | 44 | def return_book(self): 45 | book_id = self.book_id_var.get() 46 | book_id = int(book_id) 47 | 48 | if book_id in self.all_book_id(): 49 | status = 'issued' 50 | if status in db.select_book_status(book_id): 51 | book_detl = db.select_issued_book_det(book_id) 52 | 53 | std_exp_dt = datetime.datetime.strptime(book_detl[2], "%Y-%m-%d %H:%M:%S") 54 | if std_exp_dt < datetime.datetime.now(): 55 | fine = self.total_fine(std_exp_dt) 56 | conf = askyesno(title="Fine Confirmation",message=f"Student is fined, {fine[0]} for {fine[1]} days extra. Is Student submitted fine?") 57 | if conf: 58 | self.save_fine_details(book_detl[0],book_detl[1],book_detl[2],fine) 59 | self.return_book_func(book_id) 60 | else: 61 | misl_conf = askyesno(title="Miscellaneous", message="Do you want to put this book in Miscellaneous type?") 62 | if misl_conf: 63 | try: 64 | db.update_book_status(book_id,'miscellaneous') 65 | db.move_to_miscellaneous(book_id) 66 | showinfo(title='Success',message='Successfully moved in miscellaneous section.') 67 | except: 68 | showerror(title='Server Error',message='Something went wrong. Try Again!') 69 | else: 70 | showerror(title="Error - fine",message="Please take the fine!") 71 | else: 72 | self.return_book_func(book_id) 73 | 74 | else: 75 | showerror(title="Not Issued",message="Given book is not issued to anyone.") 76 | else: 77 | showerror(title="Not Found", message="No any book with given id.") 78 | 79 | def all_book_id(self): 80 | all_bookID = [] 81 | for i in db.all_book_id(): 82 | all_bookID.append(i[0]) 83 | return all_bookID 84 | 85 | def return_book_func(self,book_id): 86 | res1 = db.return_book(book_id) 87 | res2 = db.update_book_status(book_id,"available") 88 | if res1 == "returned": 89 | showinfo(title="Book Returned",message=f"Book ID - {book_id}, returned to library successfully!") 90 | else: 91 | showerror(title="ERROR",message="Something went wrong! Try Again....") 92 | 93 | def total_fine(self,exp_dt): 94 | delta = datetime.datetime.now() - exp_dt 95 | total_fine = delta.days * self.charge_per_day 96 | return (total_fine, delta.days) 97 | 98 | def save_fine_details(self,book_id,student_id,issued_dt,fine): 99 | dt = datetime.datetime.now() 100 | std_dt = dt.isoformat(' ', 'seconds') 101 | data = ( 102 | book_id, 103 | student_id, 104 | issued_dt, 105 | std_dt, 106 | fine[0], 107 | fine[1] 108 | ) 109 | res = db.save_fine_detail(data) 110 | -------------------------------------------------------------------------------- /AddBook.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from database import LMS 4 | from tkinter.messagebox import showerror, showwarning, showinfo 5 | from tkcalendar import DateEntry 6 | import datetime 7 | import os 8 | import sys 9 | 10 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 11 | 12 | class AddBook(customtkinter.CTkToplevel): 13 | def __init__(self, master=None): 14 | super().__init__(master) 15 | self.title("Library Management System") 16 | self.minsize(500,400) 17 | self.maxsize(500,400) 18 | self.geometry('500x400') 19 | dt = datetime.datetime.now() 20 | dt_year = dt.year 21 | 22 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 23 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 24 | 25 | label = customtkinter.CTkLabel(master=heading_frame, text="Add New Book",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 26 | label.pack(ipady=10) 27 | 28 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 29 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 30 | 31 | main_frame.columnconfigure(1, weight=1) 32 | main_frame.columnconfigure(2, weight=1) 33 | 34 | book_id_lbel = customtkinter.CTkLabel(master=main_frame,text="Book ID",) 35 | book_id_lbel.grid(column=1,row=0,padx=5, pady=5) 36 | 37 | self.book_id_input = customtkinter.CTkEntry(master=main_frame,width=200) 38 | self.book_id_input.grid(column=2,row=0,padx=5, pady=5) 39 | 40 | book_nme_lbel = customtkinter.CTkLabel(master=main_frame,text="Book Name",) 41 | book_nme_lbel.grid(column=1,row=1,padx=5, pady=5) 42 | 43 | self.book_nme_input = customtkinter.CTkEntry(master=main_frame,width=200) 44 | self.book_nme_input.grid(column=2,row=1,padx=5, pady=5) 45 | 46 | book_author_lbel = customtkinter.CTkLabel(master=main_frame,text="Book Author",) 47 | book_author_lbel.grid(column=1,row=2,padx=5, pady=5) 48 | 49 | self.book_author_input = customtkinter.CTkEntry(master=main_frame,width=200) 50 | self.book_author_input.grid(column=2,row=2,padx=5, pady=5) 51 | 52 | book_edition_lbel = customtkinter.CTkLabel(master=main_frame,text="Book Edition",) 53 | book_edition_lbel.grid(column=1,row=3,padx=5, pady=5) 54 | 55 | self.book_edition_input = customtkinter.CTkEntry(master=main_frame,width=200) 56 | self.book_edition_input.grid(column=2,row=3,padx=5, pady=5) 57 | 58 | book_price_lbel = customtkinter.CTkLabel(master=main_frame,text="Book Price",) 59 | book_price_lbel.grid(column=1,row=4,padx=5, pady=5) 60 | 61 | self.book_price_input = customtkinter.CTkEntry(master=main_frame,width=200) 62 | self.book_price_input.grid(column=2,row=4,padx=5, pady=5) 63 | 64 | purchase_dt_lbel = customtkinter.CTkLabel(master=main_frame,text="Purchased Date",) 65 | purchase_dt_lbel.grid(column=1,row=5,padx=5, pady=5) 66 | 67 | self.purch_dt_var = customtkinter.StringVar(self) 68 | self.purchase_dt = DateEntry(main_frame, width=10,borderwidth=2, year=dt_year, textvariable=self.purch_dt_var) 69 | self.purchase_dt.grid(column=2,row=5,padx=5, pady=5) 70 | 71 | add_new_book_btn = customtkinter.CTkButton(master=main_frame,text="Add Book", font=customtkinter.CTkFont(family="Verdana",size=16, weight="bold"),command=self.save_new_book) 72 | add_new_book_btn.grid(column=2,row=6,padx=10,pady=5,ipadx=10,ipady=10) 73 | 74 | def save_new_book(self): 75 | book_id = self.book_id_input.get() 76 | book_nme = self.book_nme_input.get() 77 | book_author = self.book_author_input.get() 78 | book_edition = self.book_edition_input.get() 79 | book_price = self.book_price_input.get() 80 | purchase_dt = self.purch_dt_var.get() 81 | if book_id != "" and book_nme != "" and book_author != "" and book_edition != "" and book_price != "" and purchase_dt != "": 82 | data = ( 83 | book_id, 84 | book_nme, 85 | book_author, 86 | book_edition, 87 | book_price, 88 | purchase_dt, 89 | "available" 90 | ) 91 | 92 | res = db.add_new_book(data) 93 | if res != None or res != '': 94 | self.book_id_input.delete(0,'end') 95 | self.book_nme_input.delete(0,'end') 96 | self.book_author_input.delete(0,'end') 97 | self.book_edition_input.delete(0,'end') 98 | self.book_price_input.delete(0,'end') 99 | #self.purchase_dt_inp.delete(0,'end') 100 | showinfo(title="Saved",message="New book saved successfully.") 101 | else: 102 | showerror(title="Not Saved",message="Something went wrong. Please try again...") 103 | else: 104 | showerror(title="Empty Fields",message="Please fill all the details then submit!") 105 | -------------------------------------------------------------------------------- /EditBook.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from database import LMS 4 | from tkinter.messagebox import showerror, showwarning, showinfo 5 | from tkcalendar import DateEntry 6 | import os 7 | import sys 8 | 9 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 10 | 11 | class EditBook(customtkinter.CTkToplevel): 12 | def __init__(self, master=None): 13 | super().__init__(master) 14 | self.title("Library Management System") 15 | self.minsize(500,490) 16 | self.maxsize(500,490) 17 | self.geometry('500x490') 18 | 19 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 20 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 21 | 22 | label = customtkinter.CTkLabel(master=heading_frame, text="Edit Book",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 23 | label.pack(ipady=10) 24 | 25 | first_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 26 | first_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 27 | 28 | book_id_lbel1 = customtkinter.CTkLabel(master=first_frame,text="Book ID",font=customtkinter.CTkFont(family="Verdana",size=16, weight="bold")) 29 | book_id_lbel1.grid(column=1,row=0,padx=10, pady=10) 30 | 31 | self.book_id_input1 = customtkinter.CTkEntry(master=first_frame,width=200) 32 | self.book_id_input1.grid(column=2,row=0,padx=5, pady=10) 33 | 34 | search_book_det_btn = customtkinter.CTkButton(master=first_frame,text="Search", font=customtkinter.CTkFont(family="Verdana",size=16, weight="bold"),command=self.search_book_detail) 35 | search_book_det_btn.grid(column=3,row=0,padx=5,pady=10) 36 | 37 | self.main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 38 | self.main_frame.pack_forget() 39 | 40 | self.main_frame.columnconfigure(1, weight=1) 41 | self.main_frame.columnconfigure(2, weight=1) 42 | 43 | book_id_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Book ID",) 44 | book_id_lbel.grid(column=1,row=0,padx=5, pady=5) 45 | 46 | self.id_var = customtkinter.StringVar(self) 47 | self.book_id_input = customtkinter.CTkEntry(master=self.main_frame,width=200, textvariable=self.id_var, state='disabled') 48 | self.book_id_input.grid(column=2,row=0,padx=5, pady=5) 49 | 50 | book_nme_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Book Name",) 51 | book_nme_lbel.grid(column=1,row=1,padx=5, pady=5) 52 | 53 | self.name_var = customtkinter.StringVar(self) 54 | self.book_nme_input = customtkinter.CTkEntry(master=self.main_frame,width=200, textvariable=self.name_var) 55 | self.book_nme_input.grid(column=2,row=1,padx=5, pady=5) 56 | 57 | book_author_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Book Author",) 58 | book_author_lbel.grid(column=1,row=2,padx=5, pady=5) 59 | 60 | self.author_var = customtkinter.StringVar(self) 61 | self.book_author_input = customtkinter.CTkEntry(master=self.main_frame,width=200, textvariable=self.author_var) 62 | self.book_author_input.grid(column=2,row=2,padx=5, pady=5) 63 | 64 | book_edition_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Book Edition",) 65 | book_edition_lbel.grid(column=1,row=3,padx=5, pady=5) 66 | 67 | self.edition_var = customtkinter.StringVar(self) 68 | self.book_edition_input = customtkinter.CTkEntry(master=self.main_frame,width=200, textvariable=self.edition_var) 69 | self.book_edition_input.grid(column=2,row=3,padx=5, pady=5) 70 | 71 | book_price_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Book Price",) 72 | book_price_lbel.grid(column=1,row=4,padx=5, pady=5) 73 | 74 | self.price_var = customtkinter.StringVar(self) 75 | self.book_price_input = customtkinter.CTkEntry(master=self.main_frame,width=200, textvariable=self.price_var) 76 | self.book_price_input.grid(column=2,row=4,padx=5, pady=5) 77 | 78 | purchase_dt_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Purchased Date",) 79 | purchase_dt_lbel.grid(column=1,row=5,padx=5, pady=5) 80 | 81 | self.purchase_dt_var = customtkinter.StringVar(self) 82 | self.purchase_dt = DateEntry(self.main_frame, width=10,borderwidth=2, textvariable=self.purchase_dt_var) 83 | self.purchase_dt.grid(column=2,row=5,padx=5, pady=5) 84 | 85 | update_new_book_btn = customtkinter.CTkButton(master=self.main_frame,text="Update", font=customtkinter.CTkFont(family="Verdana",size=16, weight="bold"),command=self.update_book) 86 | update_new_book_btn.grid(column=2,row=6,padx=10,pady=5,ipadx=10,ipady=10) 87 | 88 | def search_book_detail(self): 89 | book_id = self.book_id_input1.get() 90 | book_id = int(book_id) 91 | book_details = db.select_book_detail(book_id) 92 | if book_details != None: 93 | self.id_var.set(book_details[0]) 94 | self.name_var.set(book_details[1]) 95 | self.author_var.set(book_details[2]) 96 | self.edition_var.set(book_details[3]) 97 | self.price_var.set(book_details[4]) 98 | self.purchase_dt_var.set(book_details[5]) 99 | self.main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 100 | else: 101 | showerror(title="Not Found", message="Book Not Found") 102 | 103 | 104 | def update_book(self): 105 | book_id = self.id_var.get() 106 | book_nme = self.name_var.get() 107 | book_author = self.author_var.get() 108 | book_edition = self.edition_var.get() 109 | book_price = self.price_var.get() 110 | purchase_dt = self.purchase_dt_var.get() 111 | if book_id != "" and book_nme != "" and book_author != "" and book_edition != "" and book_price != "" and purchase_dt != "": 112 | data = ( 113 | book_id, 114 | book_nme, 115 | book_author, 116 | book_edition, 117 | book_price, 118 | purchase_dt, 119 | book_id 120 | ) 121 | 122 | res = db.update_book_details(data) 123 | if res != None or res != '': 124 | showinfo(title="Saved",message="Book updated successfully.") 125 | else: 126 | showerror(title="Not Saved",message="Something went wrong. Please try again...") 127 | else: 128 | showerror(title="Empty Fields",message="Please fill all the details then submit!") 129 | 130 | -------------------------------------------------------------------------------- /Miscellaneous.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from tkinter import ttk 4 | from database import LMS 5 | from tkinter.messagebox import showinfo 6 | import os 7 | import sys 8 | 9 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 10 | 11 | 12 | class Miscellaneous(customtkinter.CTkToplevel): 13 | def __init__(self, master=None): 14 | super().__init__(master) 15 | self.title("Library Management System") 16 | self.minsize(1300,450) 17 | self.maxsize(1300,450) 18 | self.geometry('1300x450') 19 | 20 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 21 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 22 | 23 | label = customtkinter.CTkLabel(master=heading_frame, text="Miscellaneous Books",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 24 | label.pack(ipady=10) 25 | 26 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 27 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 28 | 29 | columns = ('book_id', 'book_name', 'book_author', 'book_edition', 'book_price', 'purchase_dt', 'status') 30 | 31 | self.tree = ttk.Treeview(main_frame, columns=columns, show='headings') 32 | 33 | # define headings 34 | self.tree.heading('book_id', text='Book ID') 35 | self.tree.heading('book_name', text='Name') 36 | self.tree.heading('book_author', text='Author') 37 | self.tree.heading('book_edition', text='Edition') 38 | self.tree.heading('book_price', text='Price') 39 | self.tree.heading('purchase_dt', text='Purchased Date') 40 | self.tree.heading('status', text='Status') 41 | 42 | self.load_book_data() 43 | 44 | self.tree.bind('<>', self.item_selected) 45 | 46 | self.tree.grid(row=0,column=0,sticky='nsew') 47 | 48 | scrollbar = customtkinter.CTkScrollbar(main_frame, orientation='vertical', command=self.tree.yview) 49 | self.tree.configure(yscroll=scrollbar.set) 50 | scrollbar.grid(row=0,column=1,sticky='ns') 51 | 52 | def load_book_data(self): 53 | book_list = db.miscellaneous_books() 54 | for i in book_list: 55 | self.tree.insert('', tkinter.END, values=i) 56 | 57 | def item_selected(self,event): 58 | for selected_item in self.tree.selection(): 59 | item = self.tree.item(selected_item) 60 | record = item['values'] 61 | 62 | self.details_win(record) 63 | 64 | def details_win(self,record): 65 | window = customtkinter.CTkToplevel(self) 66 | window.title("Library Management System") 67 | window.minsize(430,630) 68 | window.maxsize(430,630) 69 | window.geometry('430x630') 70 | 71 | main_frame = customtkinter.CTkFrame(master=window,corner_radius=10,height=100) 72 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 73 | 74 | label = customtkinter.CTkLabel(master=main_frame, text="Details",font=customtkinter.CTkFont(family="Robot", size=30, weight="bold"),fg_color="#ca1a27",corner_radius=8,width=150) 75 | label.grid(column=0,row=0,pady=15,padx=5,ipadx=5,ipady=5,sticky='e') 76 | 77 | lbel1 = customtkinter.CTkLabel(master=main_frame,text="Book ID :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 78 | lbel1.grid(column=0,row=1,padx=5, pady=5,sticky='e') 79 | 80 | tvar1 = customtkinter.IntVar(window,record[0]) 81 | inp1 = customtkinter.CTkEntry(master=main_frame,font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar1) 82 | inp1.grid(column=1,row=1,padx=5, pady=5,sticky='w') 83 | 84 | lbel3 = customtkinter.CTkLabel(master=main_frame,text="Book Name :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 85 | lbel3.grid(column=0,row=2,padx=5, pady=5,sticky='e') 86 | 87 | tvar2 = customtkinter.StringVar(window,record[1]) 88 | lbel4 = customtkinter.CTkEntry(master=main_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar2) 89 | lbel4.grid(column=1,row=2,padx=5, pady=5,sticky='w') 90 | 91 | lbel5 = customtkinter.CTkLabel(master=main_frame,text="Book Author :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 92 | lbel5.grid(column=0,row=3,padx=5, pady=5,sticky='e') 93 | 94 | tvar3 = customtkinter.StringVar(window,record[2]) 95 | lbel6 = customtkinter.CTkEntry(master=main_frame,font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar3) 96 | lbel6.grid(column=1,row=3,padx=5, pady=5,sticky='w') 97 | 98 | lbel7 = customtkinter.CTkLabel(master=main_frame,text="Book Edition :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 99 | lbel7.grid(column=0,row=4,padx=5, pady=5,sticky='e') 100 | 101 | tvar4 = customtkinter.StringVar(window,record[3]) 102 | lbel8 = customtkinter.CTkEntry(master=main_frame,font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar4) 103 | lbel8.grid(column=1,row=4,padx=5, pady=5,sticky='w') 104 | 105 | lbel9 = customtkinter.CTkLabel(master=main_frame,text="Book Price :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 106 | lbel9.grid(column=0,row=5,padx=5, pady=5,sticky='e') 107 | 108 | tvar5 = customtkinter.StringVar(window,record[4]) 109 | lbel10 = customtkinter.CTkEntry(master=main_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar5) 110 | lbel10.grid(column=1,row=5,padx=5, pady=5,sticky='w') 111 | 112 | lbel11 = customtkinter.CTkLabel(master=main_frame,text="Purchase Date:",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 113 | lbel11.grid(column=0,row=6,padx=5, pady=5,sticky='e') 114 | 115 | tvar6 = customtkinter.StringVar(window,record[5]) 116 | lbel12 = customtkinter.CTkEntry(master=main_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar6) 117 | lbel12.grid(column=1,row=6,padx=5, pady=5,sticky='w') 118 | lb1 = customtkinter.CTkLabel(master=window,text="Miscellaneous Book",fg_color="#e30f67",corner_radius=8,font=customtkinter.CTkFont(family='Tahoma',size=20,weight='bold')) 119 | lb1.pack(ipady=5,ipadx=5,fill='x',anchor='n') 120 | 121 | 122 | -------------------------------------------------------------------------------- /database.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | import openpyxl 3 | 4 | 5 | class LMS: 6 | def __init__(self, db): 7 | self.conn = sqlite3.connect(db) 8 | self.cur = self.conn.cursor() 9 | 10 | def add_new_book(self, data): 11 | """ 12 | Add a new book into the books table 13 | :param self: 14 | :param data: list with book details 15 | :return: book id 16 | """ 17 | sql = '''INSERT INTO books(book_id,book_name,book_author,book_edition,book_price,date_of_purchase,status) 18 | VALUES(?,?,?,?,?,?,?)''' 19 | self.cur.execute(sql, data) 20 | self.conn.commit() 21 | return self.cur.lastrowid 22 | 23 | 24 | def add_new_student(self, xl_file): 25 | wb = openpyxl.load_workbook(xl_file) 26 | sheet = wb['Sheet1'] 27 | for row in sheet.rows: 28 | dt = [cell.value for cell in row] 29 | sql = '''INSERT INTO student (id,name,class) 30 | VALUES(?,?,?) ''' 31 | self.cur.execute(sql, dt) 32 | self.conn.commit() 33 | return self.cur.lastrowid 34 | 35 | 36 | def delete_book(self, book_id): 37 | """ 38 | Delete a book by book id 39 | :param self: 40 | :param book_id: id of book 41 | :return error or deleted 42 | """ 43 | try: 44 | sql = 'DELETE FROM books WHERE book_id=?' 45 | self.cur.execute(sql, (book_id,)) 46 | self.conn.commit() 47 | return "deleted" 48 | except: 49 | return "error" 50 | 51 | def view_book_list(self): 52 | """ 53 | Query all book rows in the books table 54 | :param self: 55 | :return: all book list 56 | """ 57 | self.cur.execute("SELECT * FROM books WHERE status = ? or status = ?",('available','issued')) 58 | return self.cur.fetchall() 59 | 60 | def miscellaneous_books(self): 61 | self.cur.execute("SELECT * FROM books WHERE status = 'miscellaneous'") 62 | return self.cur.fetchall() 63 | 64 | def view_issued_book(self,id): 65 | self.cur.execute("SELECT * FROM issued_book WHERE book_id = ? and is_miscellaneous = ?", (id,0)) 66 | return self.cur.fetchone() 67 | 68 | def view_student(self,id): 69 | self.cur.execute("SELECT * FROM student WHERE id = ?", (id,)) 70 | return self.cur.fetchone() 71 | 72 | def all_book_id(self): 73 | """ 74 | Query all book id in the books table 75 | :param self: 76 | :return: all available book id list 77 | """ 78 | self.cur.execute("SELECT book_id FROM books WHERE status = ? or status = ?", ('available','issued')) 79 | return self.cur.fetchall() 80 | 81 | def all_student_id(self): 82 | """ 83 | Query all student id in the student table 84 | :param self: 85 | :return: all available student id list 86 | """ 87 | self.cur.execute("SELECT id FROM student") 88 | return self.cur.fetchall() 89 | 90 | def issue_book(self,data): 91 | """ 92 | Issue a new book into the issued_book table 93 | :param self: 94 | :param data: list with issue book details 95 | :return: book id 96 | """ 97 | sql = '''INSERT INTO issued_book (book_id,issued_to,issued_on,expired_on) 98 | VALUES(?,?,?,?) ''' 99 | self.cur.execute(sql, data) 100 | self.conn.commit() 101 | return self.cur.lastrowid 102 | 103 | def delete_issued_book(self): 104 | try: 105 | sql = 'DELETE FROM issued_book' 106 | self.cur.execute(sql) 107 | self.conn.commit() 108 | return "deleted" 109 | except: 110 | return "error" 111 | 112 | def all_issued_book_id(self): 113 | """ 114 | Query all issued book id in the issued book table 115 | :param self: 116 | :return: all issued book id list 117 | """ 118 | self.cur.execute("SELECT book_id FROM issued_book WHERE is_miscellaneous = ?",(0,)) 119 | return self.cur.fetchall() 120 | 121 | def return_book(self,book_id): 122 | """ 123 | Return the book which issued by id 124 | :param self: 125 | :param book_id: id of book 126 | :return error or returned 127 | """ 128 | try: 129 | sql = 'DELETE FROM issued_book WHERE book_id=?' 130 | self.cur.execute(sql, (book_id,)) 131 | self.conn.commit() 132 | return "returned" 133 | except: 134 | return "error" 135 | 136 | def update_book_status(self,book_id,status): 137 | """ 138 | update book status of a book 139 | :param conn: 140 | :param book_id: id of book 141 | :param status: status of book 142 | :return: 143 | """ 144 | sql = '''UPDATE books SET status = ? WHERE book_id = ?''' 145 | self.cur.execute(sql,(status,book_id,)) 146 | self.conn.commit() 147 | 148 | def select_book_status(self,book_id): 149 | """ 150 | Query book status by book_id 151 | :param self: 152 | :param book_id: 153 | :return: book status 154 | """ 155 | self.cur.execute("SELECT status FROM books WHERE book_id=?", (book_id,)) 156 | return self.cur.fetchone() 157 | 158 | def select_issued_book_det(self,book_id): 159 | self.cur.execute("SELECT * FROM issued_book WHERE book_id=?", (book_id,)) 160 | return self.cur.fetchone() 161 | 162 | def select_book_detail(self,book_id): 163 | self.cur.execute("SELECT * FROM books WHERE book_id=?", (book_id,)) 164 | return self.cur.fetchone() 165 | 166 | def all_available_book(self): 167 | sql="SELECT book_id, book_name, book_author, book_edition, book_price FROM books WHERE status = 'available'" 168 | return (sql,self.conn) 169 | 170 | def all_issued_book(self): 171 | sql="SELECT book_id, book_name, book_author, book_edition, book_price FROM books WHERE status = 'issued'" 172 | return (sql,self.conn) 173 | 174 | def all_books(self): 175 | sql="SELECT book_id, book_name, book_author, book_edition, book_price FROM books WHERE status = 'available' or status = 'issued'" 176 | return (sql,self.conn) 177 | 178 | def fine_detail(self): 179 | sql="SELECT * FROM fine_details" 180 | return (sql,self.conn) 181 | 182 | def move_to_miscellaneous(self,id): 183 | sql = '''UPDATE issued_book SET is_miscellaneous = ? WHERE book_id = ?''' 184 | self.cur.execute(sql,(1,id,)) 185 | self.conn.commit() 186 | 187 | def update_book_details(self,data): 188 | sql = '''UPDATE books SET book_id = ?,book_name = ?,book_author = ?,book_edition = ?,book_price = ?,date_of_purchase = ? WHERE book_id = ?''' 189 | self.cur.execute(sql,data) 190 | self.conn.commit() 191 | 192 | def save_fine_detail(self,data): 193 | sql = '''INSERT INTO fine_details(book_id,student_id,issued_on,returned_date,total_fine,no_of_day) 194 | VALUES(?,?,?,?,?,?)''' 195 | self.cur.execute(sql, data) 196 | self.conn.commit() 197 | return self.cur.lastrowid -------------------------------------------------------------------------------- /ViewBooks.py: -------------------------------------------------------------------------------- 1 | import customtkinter 2 | import tkinter 3 | from tkinter import ttk 4 | from database import LMS 5 | from tkinter.messagebox import showinfo 6 | import datetime 7 | import os 8 | import sys 9 | 10 | db = LMS(os.path.join(os.path.dirname(sys.executable), "lms.db")) 11 | 12 | 13 | class ViewBooks(customtkinter.CTkToplevel): 14 | def __init__(self, master=None): 15 | super().__init__(master) 16 | self.title("Library Management System") 17 | self.minsize(1300,450) 18 | self.maxsize(1300,450) 19 | self.geometry('1300x450') 20 | 21 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 22 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 23 | 24 | label = customtkinter.CTkLabel(master=heading_frame, text="View Book",font=customtkinter.CTkFont(family="Robot",size=25, weight="bold")) 25 | label.pack(ipady=10) 26 | 27 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 28 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 29 | 30 | columns = ('book_id', 'book_name', 'book_author', 'book_edition', 'book_price', 'purchase_dt', 'status') 31 | 32 | self.tree = ttk.Treeview(main_frame, columns=columns, show='headings') 33 | 34 | # define headings 35 | self.tree.heading('book_id', text='Book ID') 36 | self.tree.heading('book_name', text='Name') 37 | self.tree.heading('book_author', text='Author') 38 | self.tree.heading('book_edition', text='Edition') 39 | self.tree.heading('book_price', text='Price') 40 | self.tree.heading('purchase_dt', text='Purchased Date') 41 | self.tree.heading('status', text='Status') 42 | 43 | self.load_book_data() 44 | 45 | self.tree.bind('<>', self.item_selected) 46 | 47 | self.tree.grid(row=0,column=0,sticky='nsew') 48 | 49 | scrollbar = customtkinter.CTkScrollbar(main_frame, orientation='vertical', command=self.tree.yview) 50 | self.tree.configure(yscroll=scrollbar.set) 51 | scrollbar.grid(row=0,column=1,sticky='ns') 52 | 53 | def load_book_data(self): 54 | book_list = db.view_book_list() 55 | for i in book_list: 56 | self.tree.insert('', tkinter.END, values=i) 57 | 58 | def item_selected(self,event): 59 | for selected_item in self.tree.selection(): 60 | item = self.tree.item(selected_item) 61 | record = item['values'] 62 | 63 | self.details_win(record) 64 | 65 | def details_win(self,record): 66 | window = customtkinter.CTkToplevel(self) 67 | window.title("Library Management System") 68 | window.minsize(430,630) 69 | window.maxsize(430,630) 70 | window.geometry('430x630') 71 | 72 | main_frame = customtkinter.CTkFrame(master=window,corner_radius=10,height=100) 73 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 74 | 75 | label = customtkinter.CTkLabel(master=main_frame, text="Details",font=customtkinter.CTkFont(family="Robot", size=30, weight="bold"),fg_color="#ca1a27",corner_radius=8,width=150) 76 | label.grid(column=0,row=0,pady=15,padx=5,ipadx=5,ipady=5,sticky='e') 77 | 78 | lbel1 = customtkinter.CTkLabel(master=main_frame,text="Book ID :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 79 | lbel1.grid(column=0,row=1,padx=5, pady=5,sticky='e') 80 | 81 | tvar1 = customtkinter.IntVar(window,record[0]) 82 | inp1 = customtkinter.CTkEntry(master=main_frame,font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar1) 83 | inp1.grid(column=1,row=1,padx=5, pady=5,sticky='w') 84 | 85 | lbel3 = customtkinter.CTkLabel(master=main_frame,text="Book Name :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 86 | lbel3.grid(column=0,row=2,padx=5, pady=5,sticky='e') 87 | 88 | tvar2 = customtkinter.StringVar(window,record[1]) 89 | lbel4 = customtkinter.CTkEntry(master=main_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar2) 90 | lbel4.grid(column=1,row=2,padx=5, pady=5,sticky='w') 91 | 92 | lbel5 = customtkinter.CTkLabel(master=main_frame,text="Book Author :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 93 | lbel5.grid(column=0,row=3,padx=5, pady=5,sticky='e') 94 | 95 | tvar3 = customtkinter.StringVar(window,record[2]) 96 | lbel6 = customtkinter.CTkEntry(master=main_frame,font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar3) 97 | lbel6.grid(column=1,row=3,padx=5, pady=5,sticky='w') 98 | 99 | lbel7 = customtkinter.CTkLabel(master=main_frame,text="Book Edition :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 100 | lbel7.grid(column=0,row=4,padx=5, pady=5,sticky='e') 101 | 102 | tvar4 = customtkinter.StringVar(window,record[3]) 103 | lbel8 = customtkinter.CTkEntry(master=main_frame,font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar4) 104 | lbel8.grid(column=1,row=4,padx=5, pady=5,sticky='w') 105 | 106 | lbel9 = customtkinter.CTkLabel(master=main_frame,text="Book Price :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 107 | lbel9.grid(column=0,row=5,padx=5, pady=5,sticky='e') 108 | 109 | tvar5 = customtkinter.StringVar(window,record[4]) 110 | lbel10 = customtkinter.CTkEntry(master=main_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar5) 111 | lbel10.grid(column=1,row=5,padx=5, pady=5,sticky='w') 112 | 113 | lbel11 = customtkinter.CTkLabel(master=main_frame,text="Purchase Date:",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 114 | lbel11.grid(column=0,row=6,padx=5, pady=5,sticky='e') 115 | 116 | tvar6 = customtkinter.StringVar(window,record[5]) 117 | lbel12 = customtkinter.CTkEntry(master=main_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=220,state='disabled', textvariable=tvar6) 118 | lbel12.grid(column=1,row=6,padx=5, pady=5,sticky='w') 119 | 120 | if record[6] == 'available': 121 | lb1 = customtkinter.CTkLabel(master=window,text="Available in Library",fg_color="#0dcd6a",corner_radius=8,font=customtkinter.CTkFont(family='Tahoma',size=25,weight='bold')) 122 | lb1.pack(ipady=5,ipadx=5,fill='x',anchor='n') 123 | elif record[6] == 'issued': 124 | lb1 = customtkinter.CTkLabel(master=window,text="Book is issued, details below",fg_color="#e30f67",corner_radius=8,font=customtkinter.CTkFont(family='Tahoma',size=20,weight='bold')) 125 | lb1.pack(ipady=5,ipadx=5,fill='x',anchor='n') 126 | 127 | sec_frame = customtkinter.CTkFrame(master=window,corner_radius=10) 128 | sec_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 129 | 130 | isu_book_dtail = db.view_issued_book(record[0]) 131 | stu_detail = db.view_student(isu_book_dtail[1]) 132 | 133 | l1 = customtkinter.CTkLabel(master=sec_frame,text="Student ID :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 134 | l1.grid(column=0,row=1,padx=5, pady=5,sticky='e') 135 | 136 | tv1 = customtkinter.StringVar(window,stu_detail[0]) 137 | in1 = customtkinter.CTkEntry(master=sec_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=210,state='disabled', textvariable=tv1) 138 | in1.grid(column=1,row=1,padx=5, pady=5,sticky='w') 139 | 140 | l2 = customtkinter.CTkLabel(master=sec_frame,text="Student Name :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 141 | l2.grid(column=0,row=2,padx=5, pady=5,sticky='e') 142 | 143 | tv2 = customtkinter.StringVar(window,stu_detail[1]) 144 | in2 = customtkinter.CTkEntry(master=sec_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=210,state='disabled', textvariable=tv2) 145 | in2.grid(column=1,row=2,padx=5, pady=5,sticky='w') 146 | 147 | l3 = customtkinter.CTkLabel(master=sec_frame,text="Student Class :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 148 | l3.grid(column=0,row=3,padx=5, pady=5,sticky='e') 149 | 150 | tv3 = customtkinter.StringVar(window,stu_detail[2]) 151 | in3 = customtkinter.CTkEntry(master=sec_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=210,state='disabled', textvariable=tv3) 152 | in3.grid(column=1,row=3,padx=5, pady=5,sticky='w') 153 | 154 | isu_dt = datetime.datetime.strptime(isu_book_dtail[2], "%Y-%m-%d %H:%M:%S") 155 | exp_dt = datetime.datetime.strptime(isu_book_dtail[3], "%Y-%m-%d %H:%M:%S") 156 | 157 | l4 = customtkinter.CTkLabel(master=sec_frame,text="Issued Date :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 158 | l4.grid(column=0,row=4,padx=5, pady=5,sticky='e') 159 | 160 | tv4 = customtkinter.StringVar(window,isu_dt.strftime("%b %d %Y, %I:%M:%S")) 161 | in4 = customtkinter.CTkEntry(master=sec_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=210,state='disabled', textvariable=tv4) 162 | in4.grid(column=1,row=4,padx=5, pady=5,sticky='w') 163 | 164 | l5 = customtkinter.CTkLabel(master=sec_frame,text="Return Date :",font=customtkinter.CTkFont(family="Verdana", size=25, weight="normal")) 165 | l5.grid(column=0,row=5,padx=5, pady=5,sticky='e') 166 | 167 | tv5 = customtkinter.StringVar(window,exp_dt.strftime("%b %d %Y, %I:%M:%S")) 168 | in5 = customtkinter.CTkEntry(master=sec_frame, font=customtkinter.CTkFont(family="Verdana", size=20, weight="normal"),width=210,state='disabled', textvariable=tv5) 169 | in5.grid(column=1,row=5,padx=5, pady=5,sticky='w') 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | import customtkinter 3 | from AddBook import * 4 | from EditBook import * 5 | from DeleteBook import * 6 | from ViewBooks import * 7 | from IssueBook import * 8 | from ReturnBook import * 9 | from BookReport import * 10 | from Miscellaneous import * 11 | import json 12 | from tkinter import filedialog 13 | from tkinter.messagebox import askokcancel 14 | import os 15 | import sys 16 | 17 | settings_file_path = os.path.join(os.path.dirname(sys.executable), 'settings.json') 18 | with open(settings_file_path, "r") as settings_file: 19 | settings = json.load(settings_file) 20 | 21 | customtkinter.set_appearance_mode(settings["theme"]) 22 | customtkinter.set_default_color_theme(settings["color_theme"]) 23 | 24 | class Setting(customtkinter.CTkToplevel): 25 | def __init__(self, master=None): 26 | super().__init__(master) 27 | self.title("Library Management System") 28 | self.minsize(300,450) 29 | self.maxsize(300,450) 30 | self.geometry('300x450') 31 | 32 | self.main_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 33 | self.main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 34 | 35 | label = customtkinter.CTkLabel(master=self.main_frame, text="Settings",font=customtkinter.CTkFont(family="Robot", size=20, weight="bold")) 36 | label.grid(column=1,row=0,ipady=10) 37 | 38 | theme_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Theme") 39 | theme_lbel.grid(column=1,row=1,padx=5, pady=5,sticky='w') 40 | 41 | self.theme_combo = customtkinter.CTkOptionMenu(self.main_frame, values=["Light", "Dark", "System"],command=self.change_theme) 42 | self.theme_combo.grid(column=2,row=1,padx=5, pady=5,sticky='e') 43 | self.theme_combo.set(settings["theme"]) 44 | 45 | color_theme_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Color Theme") 46 | color_theme_lbel.grid(column=1,row=2,padx=5, pady=5,sticky='w') 47 | 48 | self.color_theme_combo = customtkinter.CTkOptionMenu(self.main_frame, values=["blue", "dark-blue", "green"],command=self.change_theme_color) 49 | self.color_theme_combo.grid(column=2,row=2,padx=5, pady=5,sticky='e') 50 | self.color_theme_combo.set(settings["color_theme"]) 51 | 52 | issue_duration_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Issue Book Duration") 53 | issue_duration_lbel.grid(column=1,row=3,padx=5, pady=5,sticky='w') 54 | 55 | self.issue_duration_inp = customtkinter.CTkEntry(master=self.main_frame) 56 | self.issue_duration_inp.grid(column=2,row=3,padx=5,pady=5,sticky='e') 57 | self.issue_duration_inp.insert(0,settings["issue_duration"]) 58 | 59 | charge_per_day_lbel = customtkinter.CTkLabel(master=self.main_frame,text="Charge Per Day") 60 | charge_per_day_lbel.grid(column=1,row=4,padx=5, pady=5,sticky='w') 61 | 62 | self.charge_per_day_inp = customtkinter.CTkEntry(master=self.main_frame) 63 | self.charge_per_day_inp.grid(column=2,row=4,padx=5,pady=5,sticky='e') 64 | self.charge_per_day_inp.insert(0,settings["charge_per_day"]) 65 | 66 | footer_txt = customtkinter.CTkLabel(master=self.main_frame,text="Footer Text") 67 | footer_txt.grid(column=1,row=5,padx=5, pady=5,sticky='w') 68 | 69 | self.footer_txt_inp = customtkinter.CTkEntry(master=self.main_frame) 70 | self.footer_txt_inp.grid(column=2,row=5,padx=5,pady=5,sticky='e') 71 | self.footer_txt_inp.insert(0,settings["footer_txt"]) 72 | 73 | self.save_setting = customtkinter.CTkButton(master=self.main_frame, text="Save",command=self.save_settings) 74 | self.save_setting.grid(column=2,row=6,padx=5,pady=5) 75 | 76 | watermark = customtkinter.CTkLabel(master=self,text="Developed By Raunak Raj") 77 | watermark.pack(padx=10,pady=5, ipadx=5, ipady=5,fill="x",expand=True) 78 | 79 | def change_theme(self, new_theme_mode:str): 80 | settings["theme"] = new_theme_mode 81 | f = open("settings.json","w") 82 | json.dump(settings,f,indent=4) 83 | customtkinter.set_appearance_mode(new_theme_mode) 84 | 85 | def change_theme_color(self, new_theme_color:str): 86 | settings["color_theme"] = new_theme_color 87 | f = open("settings.json","w") 88 | json.dump(settings,f,indent=4) 89 | customtkinter.set_default_color_theme(new_theme_color) 90 | 91 | def change_issue_duration(self, issue_dur): 92 | settings["issue_duration"] = issue_dur 93 | f = open("settings.json","w") 94 | json.dump(settings,f,indent=4) 95 | 96 | def change_charge_per_day(self, per_day_charge): 97 | settings["charge_per_day"] = per_day_charge 98 | f = open("settings.json","w") 99 | json.dump(settings,f,indent=4) 100 | 101 | def change_footer_txt(self, txt): 102 | settings["footer_txt"] = txt 103 | f = open("settings.json","w") 104 | json.dump(settings,f,indent=4) 105 | 106 | def save_settings(self): 107 | issue_dur = self.issue_duration_inp.get() 108 | charge_per_day = self.charge_per_day_inp.get() 109 | footer_txt = self.footer_txt_inp.get() 110 | 111 | if issue_dur != None and charge_per_day != None and footer_txt != None: 112 | self.change_issue_duration(int(issue_dur)) 113 | self.change_charge_per_day(int(charge_per_day)) 114 | self.change_footer_txt(str(footer_txt)) 115 | showinfo(title="Saved",message="Settings saved successfully! Note default color theme changes works after restart.") 116 | else: 117 | showerror(title="Empty",message="Settings shouldn't empty!") 118 | 119 | class LMSApp(customtkinter.CTk): 120 | def __init__(self): 121 | super().__init__() 122 | self.title("Library Management System") 123 | self.minsize(600,430) 124 | self.maxsize(600,430) 125 | self.geometry('600x430') 126 | 127 | heading_frame = customtkinter.CTkFrame(master=self,corner_radius=10) 128 | heading_frame.pack(padx=10,pady=10, ipadx=20, ipady=5,fill="x",anchor="n") 129 | 130 | label = customtkinter.CTkLabel(master=heading_frame, text="Library Management System",font=customtkinter.CTkFont(family="Robot", size=25, weight="bold")) 131 | label.pack(ipady=10) 132 | 133 | main_frame = customtkinter.CTkFrame(master=self,corner_radius=10,fg_color='transparent') 134 | main_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True) 135 | 136 | 137 | left_frame = customtkinter.CTkFrame(master=main_frame,corner_radius=10) 138 | left_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True,side="left") 139 | 140 | right_frame = customtkinter.CTkFrame(master=main_frame,corner_radius=10) 141 | right_frame.pack(padx=10,pady=10, ipadx=5, ipady=5,fill="both",expand=True,side="right") 142 | 143 | button_1 = customtkinter.CTkButton(master=left_frame,text="Add new Book",corner_radius=3, command=self.add_book_win) 144 | button_1.pack(padx=20, pady=10) 145 | 146 | button_2 = customtkinter.CTkButton(master=left_frame,text="Delete Book",corner_radius=3, command=self.delete_book_win) 147 | button_2.pack(padx=20, pady=10) 148 | 149 | button_3 = customtkinter.CTkButton(master=left_frame,text="Book List",corner_radius=3, command=self.view_book_win) 150 | button_3.pack(padx=20, pady=10) 151 | 152 | button_4 = customtkinter.CTkButton(master=right_frame,text="Issue Book",corner_radius=3, command=self.issue_book_win) 153 | button_4.pack(padx=20, pady=10) 154 | 155 | button_5 = customtkinter.CTkButton(master=right_frame,text="Return Book",corner_radius=3, command=self.return_book_win) 156 | button_5.pack(padx=20, pady=10) 157 | 158 | button_6 = customtkinter.CTkButton(master=right_frame,text="Report",corner_radius=3, command=self.book_report_win) 159 | button_6.pack(padx=20, pady=10) 160 | 161 | button_7 = customtkinter.CTkButton(master=right_frame,text="Miscellaneous",corner_radius=3, command=self.miscellaneous_case_win) 162 | button_7.pack(padx=20, pady=10) 163 | 164 | button_8 = customtkinter.CTkButton(master=left_frame,text="Edit Book",corner_radius=3, command=self.edit_book_win) 165 | button_8.pack(padx=20, pady=10) 166 | 167 | button_9 = customtkinter.CTkButton(master=left_frame,text="Setting",corner_radius=3,fg_color='#cc0a0a',command=self.settings_win) 168 | button_9.pack(padx=20, pady=10) 169 | 170 | button_10 = customtkinter.CTkButton(master=right_frame,text="Import Student",corner_radius=3,command=self.import_student) 171 | button_10.pack(padx=20, pady=10) 172 | 173 | footer_frame = customtkinter.CTkFrame(master=self,corner_radius=8,fg_color="#f55d5d") 174 | footer_frame.pack(padx=20,pady=10,fill="x",anchor="s") 175 | dev_by_label = customtkinter.CTkLabel(master=footer_frame,text=settings["footer_txt"],bg_color="#f55d5d") 176 | dev_by_label.pack() 177 | 178 | watermark = customtkinter.CTkLabel(master=self,text="Developed By Raunak Raj") 179 | watermark.place(relx = 0.7, rely = 0.9, anchor = 'sw') 180 | 181 | def add_book_win(self): 182 | app = AddBook(self) 183 | app.focus() 184 | 185 | def edit_book_win(self): 186 | app = EditBook(self) 187 | app.focus() 188 | 189 | def delete_book_win(self): 190 | app = DeleteBook(self) 191 | app.focus() 192 | 193 | def view_book_win(self): 194 | app = ViewBooks(self) 195 | app.focus() 196 | 197 | def issue_book_win(self): 198 | app = IssueBook(self) 199 | app.focus() 200 | 201 | def return_book_win(self): 202 | app = ReturnBook(self) 203 | app.focus() 204 | 205 | def book_report_win(self): 206 | app = BookReport(self) 207 | app.focus() 208 | 209 | def miscellaneous_case_win(self): 210 | app = Miscellaneous(self) 211 | app.focus() 212 | 213 | def settings_win(self): 214 | app = Setting(self) 215 | app.focus() 216 | 217 | def import_student(self): 218 | try: 219 | filetypes = ( 220 | ('exel files', '*.xlsx'), 221 | ) 222 | file = filedialog.askopenfilename(title="Import Students",filetypes=filetypes) 223 | res = db.add_new_student(file) 224 | if res != None: 225 | showinfo(title="Success",message="Students imported successfully") 226 | else: 227 | showerror(title="Error",message="Something went wrong. Try Again!") 228 | except: 229 | showerror(title="Error",message="File is not in correct form or file not selected") 230 | 231 | if __name__ == '__main__': 232 | app = LMSApp() 233 | app.mainloop() --------------------------------------------------------------------------------