import gradio as gr
import random
# Restaurant Info
RESTAURANT_NAME = "Taste of Paradise"
THEME_COLOR = "#FF6B6B"
CONTACT = "📞 020 7123 4567 | 📍 45 Foodie Lane, London | 🕒 10AM-10PM Daily"
# Menu Items with Images and Prices
menu_items = [
{
"category": "🍟 Starters",
"items": [
{"name": "Garlic Bread", "price": 4.99, "image": "images/garlic_bread.jpg"},
{"name": "Bruschetta", "price": 5.99, "image": "images/bruschetta.jpg"}
]
},
{
"category": "🍔 Main Courses",
"items": [
{"name": "Cheese Burger", "price": 12.99, "image": "images/burger.jpg"},
{"name": "Margherita Pizza", "price": 10.99, "image": "images/pizza.jpg"}
]
},
{
"category": "🍰 Desserts",
"items": [
{"name": "Chocolate Cake", "price": 6.99, "image": "images/cake.jpg"},
{"name": "Ice Cream", "price": 4.99, "image": "images/ice_cream.jpg"}
]
}
]
def create_menu_item(item):
with gr.Column(scale=1, variant="panel"):
gr.Image(item["image"], show_label=False, height=200, width=300)
gr.Markdown(f"### {item['name']}\n"
f"**Price:** £{item['price']}")
return gr.Number(0, label="Quantity", minimum=0, step=1)
def calculate_order(*quantities):
total = 0
prices = [item["price"] for category in menu_items for item in category["items"]]
order_details = "
📝 Your Order:
"
for qty, price, category in zip(quantities, prices, [item for category in menu_items for item in category["items"]]):
if qty > 0:
total += qty * price
order_details += f"• {category['name']} x{qty} = £{qty*price:.2f}
"
order_details += f"Total: £{total:.2f}
"
return order_details
with gr.Blocks(title=RESTAURANT_NAME, theme=gr.themes.Default(primary_hue="red")) as app:
# Header Section
gr.Markdown(f"🍽️ {RESTAURANT_NAME}
")
gr.Markdown(f"{CONTACT}
")
# Menu Display
with gr.Row():
# Menu Items Column
with gr.Column(scale=3):
quantity_inputs = []
for category in menu_items:
gr.Markdown(f"## {category['category']}")
with gr.Row():
for item in category["items"]:
qty_input = create_menu_item(item)
quantity_inputs.append(qty_input)
# Order Summary Column
with gr.Column(scale=1, variant="panel"):
order_display = gr.HTML()
calculate_btn = gr.Button("Update Order", variant="primary")
calculate_btn.click(calculate_order, inputs=quantity_inputs, outputs=order_display)
# Order Confirmation
with gr.Accordion("Place Order", open=False):
name = gr.Textbox(label="Name")
table = gr.Number(label="Table Number", minimum=1)
notes = gr.Textbox(label="Special Requests")
confirm_btn = gr.Button("Confirm Order", variant="stop")
confirmation = gr.Markdown()
def confirm_order(name, table, notes):
if not name or not table:
return "❌ Please fill in all required fields"
return f"✅ Order placed successfully! Your food will be prepared for table {int(table)}"
confirm_btn.click(confirm_order, [name, table, notes], confirmation)
# Footer
gr.Markdown("---")
gr.Markdown("**Follow us:** [Instagram](https://instagram.com) | [Facebook](https://facebook.com) | [Twitter](https://twitter.com)")
if __name__ == "__main__":
app.launch()