Ip Project
Ip Project
Bhopal
Project Record
Food Ordering System
(Informatics Practices)
Session: 2024-25
Submitted To:
Ms. Sumita Shrivastava
HOD (IP)
SUBMITTED BY:
Kushagra Katiyar
Adeesh Jain
Class XII A
CERTIFICATE
Date :
_____________________ _____________________
(Principal Signature) (Institution Stamp)
_____________________ _____________________
(Internal Signature) (Examiner Signature)
ACKNOWLEDGEMENT
Kushagra Katiyar
Adeesh Jain
Class : XII
ABSTRACT
Setup
Core Features
Error Handling
Application Flow
import tkinter as tk
from tkinter import ttk, messagebox
import mysql.connector
class WelcomeWindow(tk.Tk):
def __init__(self):
super().__init__()
self.title("Hungry?")
self.geometry("600x400")
self.resizable(False, False)
self.configure(bg="#f0f0f0")
self.db = mysql.connector.connect(
host="localhost", user="root", password="root",
database="db"
)
self.cursor = self.db.cursor()
self.logged_in_user = None
def open_login_page(self):
# Hide the Welcome Window
self.withdraw()
def open_registration_page(self):
# Create a new window for the registration page
registration_page = tk.Toplevel(self)
registration_page.title("Register")
registration_page.geometry("300x200")
registration_page.config(bg="#2E2E2E")
def open_post_login_options(self):
"""Open a popup with options after successful login
or registration."""
options_popup = tk.Toplevel(self)
options_popup.title("Choose an Option")
self.center_window(300, 200, options_popup)
options_popup.config(bg="#2E2E2E")
tk.Label(
options_popup, text="Welcome!",
font=("Helvetica", 16), bg="#2E2E2E", fg="#FFF"
).pack(pady=10)
tk.Button(
options_popup,
text="Order Food",
command=lambda: [self.open_menu_window()],
width=20,
bg="#4caf50",
fg="#FFF",
).pack(pady=5)
tk.Button(
options_popup,
text="Track Order",
command=self.open_track_order(),
width=20,
bg="#4caf50",
fg="#FFF",
).pack(pady=5)
tk.Button(
options_popup,
text="Payment History",
command=self.open_payment_history(),
width=20,
bg="#4caf50",
fg="#FFF",
).pack(pady=5)
def open_track_order(self):
"""Open a popup for tracking orders (currently
empty)."""
track_order_popup = tk.Toplevel(self)
track_order_popup.title("Track Order")
self.center_window(300, 200, track_order_popup)
track_order_popup.config(bg="#2E2E2E")
tk.Label(
track_order_popup,
text="Track Order (Coming Soon)",
font=("Helvetica", 14),
bg="#2E2E2E",
fg="#FFF",
).pack(pady=20)
def open_payment_history(self):
"""Open a popup for payment history displaying user's
orders."""
if not self.logged_in_user:
messagebox.showerror("Error", "You need to log in
first.")
return
payment_history_popup = tk.Toplevel(self)
payment_history_popup.title("Payment History")
self.center_window(600, 400, payment_history_popup)
payment_history_popup.config(bg="#2E2E2E")
if not orders:
tk.Label(payment_history_popup, text="No payment
history found.", font=("Helvetica", 14), bg="#2E2E2E",
fg="#FFF").pack(pady=20)
return
def open_menu_window(self):
"""Open the menu window."""
menu_window = tk.Toplevel(self)
menu_window.title("Menu Ordering Page")
self.center_window(600, 700, menu_window)
menu_window.config(bg="#2E2E2E")
self.create_menu_ui(menu_window)
def calculate_subtotal():
subtotal = 0
selected_items.clear()
for category_vars in menu_var_lists.values():
for ((item_name, price), item_count_var) in
category_vars:
count = item_count_var.get()
if count > 0:
subtotal += price * count
selected_items.append((item_name,
price, count))
subtotal_var.set(f"{subtotal:.2f}/-")
def confirm_order():
calculate_subtotal()
if not selected_items:
messagebox.showwarning("No Items", "Please
select items to place an order.")
return
confirmation_popup = tk.Toplevel(menu_window)
confirmation_popup.title("Confirm Order")
confirmation_popup.geometry("600x750")
confirmation_popup.config(bg="#2E2E2E")
def finalize_order():
confirmation_popup.destroy()
messagebox.showinfo(
"Order Complete",
"Your order is complete. Please pick up
your order from the window number 2.",
)
tk.Button(
confirmation_popup, text="Confirm and Place
Order", command=finalize_order, bg="#444", fg="#FFF"
).pack(pady=20)
user_name = name_entry.get()
user_address = address_entry.get()
user_phone = phone_entry.get()
try:
query = """
INSERT INTO orders (name, address, phone_no,
orderITEMS, totalAMT)
VALUES (%s, %s, %s, %s, %s)
"""
values = (user_name, user_address,
user_phone, order_items_str, total_amount)
self.cursor.execute(query, values)
self.db.commit()
messagebox.showinfo(
"Order Complete",
"Please Confirm Your Order and Proceed
with Payment",
)
except Exception as e:
messagebox.showerror("Database Error", f"An
error occurred while saving the order: {e}")
address_label = tk.Label(menu_window,
text="Address:", bg="#2E2E2E", fg="#FFF")
address_label.grid(row=1, column=0, padx=10, pady=10)
address_entry = tk.Entry(menu_window, width=30)
address_entry.grid(row=1, column=1, padx=10, pady=10)
notebook = ttk.Notebook(menu_window)
notebook.grid(row=3, column=0, columnspan=2, pady=20)
menu_categories = {
"Starters": [
("Tomato Soup", 50), ("Veg Manchow Soup",
60), ("Salad", 60), ("Paneer Tikka", 120), ("Crispy Corn",
110),
("Vegetable Pakora", 80), ("Spring Rolls",
100), ("Hara Bhara Kebab", 90), ("Stuffed Mushrooms", 130),
("Corn Cheese Balls", 120), ("Veg Seekh
Kebab", 150)
],
"Main Course": [
("Paneer Butter Masala", 200), ("Shahi
Paneer", 180), ("Aloo Gobi", 130), ("Dal Makhani", 150),
("Veg Biryani", 150), ("Lemon Rice", 120),
("Mushroom Masala", 180), ("Mix Veg Curry", 160),
("Bhindi Masala", 140), ("Chana Masala",
150), ("Kofta Curry", 170)
],
"Breads": [
("Tava Roti", 15), ("Tandoori Roti", 20),
("Garlic Naan", 30), ("Paratha", 30),
("Butter Naan", 25), ("Stuffed Kulcha", 40),
("Missi Roti", 25), ("Roomali Roti", 30),
("Laccha Paratha", 35), ("Cheese Naan",
50),("Extra Butter", 20)
],
"Desserts": [
("Ice Cream", 50), ("Gulab Jamun", 50),
("Moong Dal Halwa", 60), ("Rasmalai", 60), ("Fruit Custard",
60),
("Chocolate Brownie", 80), ("Carrot Halwa",
70), ("Rasgulla", 50), ("Kulfi (Pista)", 70),
("Shahi Tukda", 80), ("Jalebi", 50)
],
}
menu_var_lists = {}
for category, items in menu_categories.items():
category_frame = ttk.Frame(notebook)
notebook.add(category_frame, text=category)
menu_var_lists[category] = []
item_count_var = tk.IntVar()
item_count_spinbox = ttk.Spinbox(
category_frame, from_=0, to=10, width=5,
textvariable=item_count_var, command=calculate_subtotal
)
item_count_spinbox.grid(row=i, column=1,
padx=10, pady=5)
menu_var_lists[category].append(((item_name,
price), item_count_var))
subtotal_label = ttk.Label(menu_window,
text="Subtotal:")
subtotal_label.grid(row=4, column=0, padx=10,
pady=10, sticky=tk.E)
subtotal_value = ttk.Label(menu_window,
textvariable=subtotal_var, font=("Helvetica", 12, "bold"))
subtotal_value.grid(row=4, column=1, padx=10,
pady=10, sticky=tk.W)
confirm_button = ttk.Button(menu_window,
text="Confirm Order", command=confirm_order)
confirm_button.grid(row=5, column=0, columnspan=2,
pady=20)
if __name__ == "__main__":
welcome_window = WelcomeWindow()
welcome_window.mainloop()
OUTPUT
Conclusion
The Food Ordering and Management System offers a streamlined and
efficient solution for modern-day order management challenges. By
leveraging Python's Tkinter for an intuitive user interface and MySQL for
robust database integration, the project successfully automates and
simplifies key aspects of order processing and tracking.
● BOOK
○ Sumita Arora, Informatics Practices, Class 12th
● Websites
○ Tkinter Basics & Understanding
■ (43) Bro Code - YouTube