geethareddy's picture
Update components/menu.py
2715eaf verified
raw
history blame
1.28 kB
import gradio as gr
from components.popup_card import generate_popup_card
def generate_menu():
menu_items = [
{"name": "Biryani", "image": "static/images/biryani.png", "model": "static/3d_models/biryani.glb"},
{"name": "Noodles", "image": "static/images/noodles.png", "model": "static/3d_models/noodles.glb"},
{"name": "Fried Rice", "image": "static/images/fried_rice.png", "model": "static/3d_models/fried_rice.glb"},
{"name": "Chicken Wings", "image": "static/images/chicken_wings.png", "model": "static/3d_models/chicken_wings.glb"},
]
def show_popup(item_name, model_path):
return generate_popup_card(item_name, model_path)
with gr.Row() as menu_row:
for item in menu_items:
with gr.Column():
gr.Image(item["image"], label=item["name"])
button = gr.Button(f"Add {item['name']}")
button.click(
show_popup,
inputs=[
gr.Textbox(value=item["name"], visible=False), # Item Name
gr.Textbox(value=item["model"], visible=False), # Model Path
],
outputs=gr.HTML() # Popup will render as HTML
)
return menu_row