import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk
import os
# Global variables
basket = []
total_price = 0
# Function to update the basket and calculate the total
def add_to_basket(item_name, item_price):
global total_price
[Link]((item_name, item_price))
total_price += item_price
update_basket_display()
# Function to update the basket display
def update_basket_display():
# Clear the current basket listbox
basket_list.delete(0, [Link]) # This ensures we don't overwrite the whole
basket
for item, price in basket:
basket_list.insert([Link], f"{item} - ${price:.2f}")
# Update the total price label
total_label.config(text=f"Total: ${total_price:.2f}")
# Function to remove the last placed item from the basket
def remove_from_basket():
if basket:
item_name, item_price = [Link]() # Remove the last item
global total_price
total_price -= item_price
update_basket_display()
else:
[Link]("Empty Basket", "There are no items in the basket to
remove.")
# Function to print receipt
def print_receipt():
receipt = "Receipt\n-----------------\n"
for item, price in basket:
receipt += f"{item} - ${price:.2f}\n"
receipt += f"-----------------\nTotal: ${total_price:.2f}"
[Link]("Receipt", receipt)
# Function to notify the restaurant
def notify_restaurant():
[Link]("Notification", "Order has been placed and the restaurant
has been notified!")
# Function to load and resize image
def load_image(path, width=80, height=80):
if not [Link](path):
print(f"File not found: {path}")
return None
try:
image = [Link](path)
image = [Link]((width, height), [Link])
return [Link](image)
except Exception as e:
print(f"Error loading image: {e}")
return None
# Create the main window
root = [Link]()
[Link]("Restaurant Order System")
[Link](bg="#d8e3e7") # Subtle blue-gray background
# Frames for food and beverages (side-by-side layout)
food_frame = [Link](root, text="Food Menu", bg="#d8e3e7", font=("Arial", 10,
"bold"), fg="#000000")
food_frame.grid(row=0, column=0, padx=10, pady=10, sticky="n")
beverage_frame = [Link](root, text="Beverage Menu", bg="#d8e3e7",
font=("Arial", 10, "bold"), fg="#000000")
beverage_frame.grid(row=0, column=1, padx=10, pady=10, sticky="n")
# Food items
food_items = [
("Pizza", 10.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Burger", 5.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Pasta", 7.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Bibimbap", 8.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
("Bulgogi", 10.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
("Dakgalbi", 9.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
("Jjimdak", 9.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
("Kimbap", 5.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Kimchi Jjigae", 6.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\kimchi_jjigae.jpg"),
("Kongguksu", 7.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
("Tteokbokki", 6.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
]
# Beverage items
beverage_items = [
("Coke", 2.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Water", 1.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Juice", 3.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Banana Juice", 3.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\banana_juice.jpg"),
("Black Tea", 2.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\black_tea.jpg"),
("Cappucino", 4.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\[Link]"),
("Cherry Juice", 3.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\cherry_juice.jpg"),
("Grapefruit Juice", 3.75, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\grapefruit_juice.jpg"),
("Honey Tea", 2.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\honey_tea.jpg"),
("Iced Latte", 4.25, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\iced_latte.jpg"),
("Latte", 4.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Lemon Tea", 2.75, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\lemon_tea.jpg"),
("Matcha", 4.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Soju", 5.00, "C:\\Users\\Asus\\OneDrive\\Desktop\\restaurant_order_system\\
images\\[Link]"),
("Strawberry Juice", 3.50, "C:\\Users\\Asus\\OneDrive\\Desktop\\
restaurant_order_system\\images\\strawberry_juice.jpg"),
]
# Add food items
for row, (name, price, image_file) in enumerate(food_items):
img = load_image(image_file)
button = [Link](food_frame, image=img, command=lambda n=name, p=price:
add_to_basket(n, p), bg="#ffffff", relief="flat")
[Link] = img
[Link](row=row // 3, column=(row % 3) * 2, padx=5, pady=5)
label = [Link](food_frame, text=f"{name}\n${price:.2f}", bg="#d8e3e7",
font=("Arial", 9))
[Link](row=row // 3, column=(row % 3) * 2 + 1, padx=5, pady=5)
# Add beverage items
for row, (name, price, image_file) in enumerate(beverage_items):
img = load_image(image_file)
button = [Link](beverage_frame, image=img, command=lambda n=name, p=price:
add_to_basket(n, p), bg="#ffffff", relief="flat")
[Link] = img
[Link](row=row // 3, column=(row % 3) * 2, padx=5, pady=5)
label = [Link](beverage_frame, text=f"{name}\n${price:.2f}", bg="#d8e3e7",
font=("Arial", 9))
[Link](row=row // 3, column=(row % 3) * 2 + 1, padx=5, pady=5)
# Basket Frame
basket_frame = [Link](root, bg="#d8e3e7")
basket_frame.grid(row=1, column=0, columnspan=2, padx=10, pady=10)
# Listbox for the basket items
basket_list = [Link](basket_frame, width=50, height=10, bg="#ffffff",
fg="#000000", font=("Arial", 9))
basket_list.grid(row=0, column=0, padx=5, pady=5)
# Total price label
total_label = [Link](basket_frame, text="Total: $0.00", font=("Arial", 12),
bg="#d8e3e7")
total_label.grid(row=1, column=0, padx=5, pady=5)
# Button Frame for Print Receipt and Notify Restaurant
button_frame = [Link](root, bg="#d8e3e7")
button_frame.grid(row=2, column=0, columnspan=2, padx=10, pady=10)
# Receipt Button
receipt_button = [Link](button_frame, text="Print Receipt",
command=print_receipt, bg="#4CAF50", fg="#ffffff", font=("Arial", 10, "bold"))
receipt_button.grid(row=0, column=0, padx=10, pady=10)
# Notify Button
notify_button = [Link](button_frame, text="Notify Restaurant",
command=notify_restaurant, bg="#4CAF50", fg="#ffffff", font=("Arial", 10, "bold"))
notify_button.grid(row=0, column=1, padx=10, pady=10)
# Remove Button (placed near the others)
remove_button = [Link](button_frame, text="Remove Last Item",
command=remove_from_basket, bg="#FF6347", fg="#ffffff", font=("Arial", 10, "bold"))
remove_button.grid(row=0, column=2, padx=10, pady=10)
[Link]()