Project 3
import tkinter as tk
from tkinter import messagebox
# Global dictionary to store the order
myOrder = {}
# Create the main application window
root = tk.Tk()
root.title("Restaurant Ordering System")
root.geometry("400x400")
# Function to display restaurant information
def show_info():
info_text = ("Restaurant Name: Kean Bytes\n"
"Location: 1000 Morris Ave, Union NJ 07083\n"
"Website: www.kean.edu")
messagebox.showinfo("Restaurant Information", info_text)
# Function to add items to the order
def add_to_order(item, price):
def confirm_order():
try:
quantity = int(quantity_entry.get())
if quantity <= 0:
raise ValueError
if item in myOrder:
myOrder[item] += quantity
else:
myOrder[item] = quantity
messagebox.showinfo("Order Updated", f"Added {quantity} {item}(s) to your order.")
quantity_window.destroy()
except ValueError:
messagebox.showwarning("Invalid Input", "Please enter a positive integer for quantity.")
# Create a new window for entering quantity
quantity_window = tk.Toplevel(root)
quantity_window.title("Enter Quantity")
quantity_window.geometry("250x100")
quantity_label = tk.Label(quantity_window, text=f"Enter quantity for {item}:")
quantity_label.pack(pady=5)
quantity_entry = tk.Entry(quantity_window, width=5)
quantity_entry.insert(0, "1")
quantity_entry.pack(pady=5)
confirm_button = tk.Button(quantity_window, text="Confirm", command=confirm_order)
confirm_button.pack(pady=5)
# Function to display the current order
def display_order():
if myOrder:
order_text = "\n".join([f"{item}: {qty}" for item, qty in myOrder.items()])
messagebox.showinfo("Your Order", order_text)
else:
messagebox.showinfo("Your Order", "No items ordered yet.")
# Function to place the order (coming soon)
def place_order():
messagebox.showinfo("Place Order", "Coming Soon!")
# Function to modify the order (coming soon)
def modify_order():
messagebox.showinfo("Modify Order", "Modify Order feature coming soon!")
# Function to clear the frame
def clear_frame():
for widget in menu_frame.winfo_children():
widget.destroy()
# Function to go back to the main menu
def show_main_menu():
clear_frame()
category_label = tk.Label(menu_frame, text="Main Menu", font=("Arial", 16))
category_label.pack(pady=10)
tk.Button(menu_frame, text="Restaurant Info", command=show_info).pack(pady=5)
tk.Button(menu_frame, text="Appetizers", command=show_appetizers).pack(pady=5)
tk.Button(menu_frame, text="Entrees", command=lambda: messagebox.showinfo("Entrees", "Coming Soon!")).pack(pady=5)
tk.Button(menu_frame, text="Desserts", command=lambda: messagebox.showinfo("Desserts", "Coming Soon!")).pack(pady=5)
tk.Button(menu_frame, text="Beverages", command=lambda: messagebox.showinfo("Beverages", "Coming Soon!")).pack(pady=5)
# Main Menu buttons
tk.Button(menu_frame, text="Display Order", command=display_order).pack(pady=5)
tk.Button(menu_frame, text="Modify Order", command=modify_order).pack(pady=5)
tk.Button(menu_frame, text="Place Order", command=place_order).pack(pady=5)
# Function to show appetizers
def show_appetizers():
# Appetizers dictionary
appetizers = {
"Garlic Bread": 5.99,
"Mozzarella Sticks": 7.99,
"Nachos": 8.99,
"Fried Pickles": 6.99,
"Stuffed Mushrooms": 9.99
}
clear_frame()
appetizer_label = tk.Label(menu_frame, text="Appetizers", font=("Arial", 14))
appetizer_label.pack()
for appetizer, price in appetizers.items():
button = tk.Button(menu_frame, text=f"{appetizer} - ${price}",
command=lambda a=appetizer, p=price: add_to_order(a, p))
button.pack(pady=2)
# Main Menu button at the bottom of the screen
main_menu_button = tk.Button(menu_frame, text="Main Menu", command=show_main_menu)
main_menu_button.pack(pady=5)
# Create main menu frame
menu_frame = tk.Frame(root)
menu_frame.pack(pady=10)
# Restaurant Information Button
info_button = tk.Button(menu_frame, text="Restaurant Info", command=show_info)
info_button.pack(pady=5)
# Show the main menu on application start
show_main_menu()
# Start the application
root.mainloop()Last updated