This project is a simple Inventory Management System built using Python and Tkinter. It allows users to manage inventory items, including adding, updating, and deleting items, as well as exporting the inventory data to a CSV file.
Add multiple items with details such as item name, cost, number, and remarks.
Quickly fill in item details from a predefined list.
Update the details of existing items in the inventory.
Remove items from the inventory.
Export the inventory data to a CSV file.
Uses SQLite to store inventory data persistently.
Class InventoryManagementSystem
__init__(self, root)
The constructor initializes the main application window and sets up the initial state of the application.
A dictionary of predefined items with their costs.
Connects to an SQLite database named inventory.db and calls create_table() to ensure the necessary table exists.
Calls create_widgets() to set up the GUI components and load_data_into_tree() to load existing data into the tree view.
Binds the Enter key to trigger the add_multiple_items() method.
create_table(self)
Creates the inventory table with columns for ID, item name, cost, number, and remarks if it doesn't already exist.
create_widgets(self)
Creates the main layout and components of the application.
A frame to input multiple items.
Adds labels for item attributes and buttons to add items, update items, delete items, and download CSV.
A table-like widget to display the inventory items with columns for ID, item name, cost, number, remarks, and total cost. The ID column is hidden.
fill_cost(self, event, cost_entry)
Fills the cost entry field based on the selected predefined item.
add_item_row(self)
Adds a new row of input fields (name, cost, number, remarks) to the items frame. add_multiple_items(self, event=None)
Loops through the input fields, validates the inputs, and inserts the items into the database. Then refreshes the tree view and clears the input fields.
update_item(self)
Opens a new window with the selected item's data pre-filled in input fields. After editing, the changes are saved back to the database.
delete_item(self, event=None)
Deletes the selected item(s) from the database and refreshes the tree view. select_item(self, event)
This method is a placeholder for future functionality (if needed).
clear_entries(self)
Clears all input fields in the items frame.
load_data_into_tree(self)
Clears the tree view and reloads all items from the database into it, calculating and displaying the total cost for each item.
download_csv(self)
Exports the inventory data to a CSV file. It retrieves the data from the database, allows the user to choose the save location, and writes the data to the file.