A simple Library Management System built using Python's Tkinter for GUI and basic class-based functionality. The system allows users to add, borrow, return, and view books in the library.
- Add a Book: Allows users to add books with details like book ID, title, author, publication year, and available copies.
- Borrow a Book: Lets users borrow books by entering the book ID. The system checks if the book is available.
- Return a Book: Users can return borrowed books by entering the book ID.
- View Available Books: Displays a list of books that are available for borrowing.
- Python 3.x
- Tkinter library (usually included with Python)
- Clone the repository:
git clone https://github.com/ridsb/library-management-system.git
- Navigate to the project folder:
cd library-management-system
- Run the application:
python library_ui.py
- This function allows users to add a new book to the library by entering details like
book_id
,title
,author
,year
, andavailable copies
. - The system validates that all fields are filled, then adds the book to the library.
- Function in UI:
add_book()
- This function lets a user borrow a book by entering its
book_id
. - The system checks if the book is available for borrowing. If so, it updates the available copies and confirms the borrowing process.
- If the book is not available, the user receives a warning.
- Function in UI:
borrow_book()
- This function allows a user to return a borrowed book by entering its
book_id
. - The system verifies whether the book was borrowed and updates the availability count.
- If the book is not found or not borrowed, the system shows an error message.
- Function in UI:
return_book()
- Displays all available books in the library.
- The system shows details like
book_id
,title
,author
,year
, and the number of available copies. - Function in UI:
view_books()
The core logic of the library is handled in the Library
class. This class manages the list of books, and provides methods to:
add_book(book_id, title, author, year, available, max_books)
: Adds a new book to the library.borrow_book(book_id)
: Checks if a book is available and reduces its available copies when borrowed.return_book(book_id)
: Increases the available copies when a book is returned.view_available_books()
: Returns a list of all available books in the library.
This class handles the graphical user interface (GUI) using Tkinter. It provides the following:
- UI Elements: Labels, entry fields, and buttons to interact with the system (add, borrow, return, and view books).
- Functions: Handles user interactions (button clicks) and calls appropriate methods in the
Library
class.
-
Adding a Book:
- Enter the book details in the "Add Book" section and click the "Add Book" button to add the book to the library system.
-
Borrowing a Book:
- Enter the book ID in the "Borrow Book" section and click the "Borrow" button to borrow the book.
-
Returning a Book:
- Enter the book ID in the "Return Book" section and click the "Return" button to return the borrowed book.
-
Viewing Available Books:
- Click the "View Available Books" button to see all the books currently available for borrowing.