Spaces:
Sleeping
Sleeping
Create components/menu.py
Browse files- components/menu.py +22 -0
components/menu.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from components.popup_card import generate_popup_card
|
| 3 |
+
|
| 4 |
+
def generate_menu():
|
| 5 |
+
menu_items = [
|
| 6 |
+
{"name": "Biryani", "image": "static/images/biryani.png", "model": "static/3d_models/biryani.glb"},
|
| 7 |
+
{"name": "Noodles", "image": "static/images/noodles.png", "model": "static/3d_models/noodles.glb"},
|
| 8 |
+
{"name": "Fried Rice", "image": "static/images/fried_rice.png", "model": "static/3d_models/fried_rice.glb"},
|
| 9 |
+
{"name": "Chicken Wings", "image": "static/images/chicken_wings.png", "model": "static/3d_models/chicken_wings.glb"},
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
with gr.Row() as menu_row:
|
| 13 |
+
for item in menu_items:
|
| 14 |
+
with gr.Column():
|
| 15 |
+
gr.Image(item["image"], label=item["name"])
|
| 16 |
+
gr.Button("Add", elem_id=f"add-{item['name']}").click(
|
| 17 |
+
generate_popup_card,
|
| 18 |
+
inputs=[item["name"], item["model"]],
|
| 19 |
+
outputs="popup-container"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
return menu_row
|