This is a simple Tkinter application that demonstrates how to create a table using the ttk.Treeview
widget with scroll bars for displaying production information. The application includes a basic structure with headings and scrollable rows.
Ensure you have Python installed on your system. You can download it from python.org.
This application uses the tkinter
library, which is included in the Python standard library. No additional dependencies are required.
Clone this repository to your local machine:
[email protected]:ebarthur/tkinter-grocery-app.git
Navigate to the project directory:
cd tkinter-grocery-app
Run the application:
python main.py
-
Install PostgreSQL: Make sure you have PostgreSQL installed on your machine. You can download it from PostgreSQL Downloads.
-
Create a Database: Open pgAdmin or any PostgreSQL management tool and create a new database named
grocery_store
. You can use the following SQL command in pgAdmin:CREATE DATABASE grocery_store;
-
Create a Table: After creating the database, execute the following SQL command to create an
inventory
table within thegrocery_store
database:CREATE TABLE inventory ( product_id VARCHAR(10), product_name VARCHAR(255), category VARCHAR(50), brand VARCHAR(50), price VARCHAR(10), stock_quantity INTEGER, supplier VARCHAR(255), expiry_date DATE, discount VARCHAR(10), location VARCHAR(50));
-
Insert Sample Data: Optionally, you can insert sample data into the
inventory
table:INSERT INTO inventory VALUES ('101', 'Banana', 'Fruits', 'Chiquita', '$0.79', 100, 'Local Farms', '2023-01-10', '5%', 'Aisle 1'), -- Add more rows as needed
**UPDATE inventory SET stock_quantity = 100 WHERE product_id = '114'::character varying;
Please note that the date format should be 'YYYY-MM-DD'.
-
Update Python Script: Open the
main.py
script and update the PostgreSQL connection details:# Connect to PostgreSQL connection = psycopg2.connect( host="localhost", database="grocery_store", user="your_postgres_user", password="your_postgres_password" )
Replace
your_postgres_user
andyour_postgres_password
with your PostgreSQL username and password.
- The application window will open, displaying a table with sample data.
- Customize the
populate_table
method inmain.py
to fetch data from your database using the appropriate method (replace the mock data with actual data).
main.py
: Contains the main application code, including theGroceryStore
class that sets up the Tkinter window and the table.commands.py
(not provided): Add your database-related commands and functions here.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.