Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,20 +42,17 @@ def create_ui():
|
|
| 42 |
gr.HTML("<h1 style='text-align: center;'>Biryani Hub Menu</h1>")
|
| 43 |
|
| 44 |
# Category Selection Buttons
|
|
|
|
| 45 |
with gr.Row():
|
| 46 |
all_button = gr.Button("ALL")
|
| 47 |
vegan_button = gr.Button("VEGAN")
|
| 48 |
halal_button = gr.Button("HALAL")
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
gr.Markdown("### Select
|
| 52 |
-
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
gr.Markdown("### Selected Items")
|
| 56 |
-
selected_dishes = gr.Dropdown(label="Select a Dish to View Details", choices=[], value=None, interactive=True)
|
| 57 |
-
|
| 58 |
-
# Section 3: Dish Details
|
| 59 |
gr.Markdown("### Dish Details")
|
| 60 |
dish_image = gr.Image(label="Dish Image", type="pil")
|
| 61 |
dish_description = gr.Textbox(label="Description", interactive=False)
|
|
@@ -63,20 +60,14 @@ def create_ui():
|
|
| 63 |
dish_spice_level = gr.Textbox(label="Spice Level", interactive=False)
|
| 64 |
dish_portion_size = gr.Textbox(label="Portion Size", interactive=False)
|
| 65 |
|
| 66 |
-
# Event: Update
|
| 67 |
-
all_button.click(fn=lambda: filter_dishes("ALL"), outputs=
|
| 68 |
-
vegan_button.click(fn=lambda: filter_dishes("VEGAN"), outputs=
|
| 69 |
-
halal_button.click(fn=lambda: filter_dishes("HALAL"), outputs=
|
| 70 |
-
|
| 71 |
-
# Event: Update selected_dishes dropdown when items are selected in dish_list
|
| 72 |
-
def update_selected_dishes(selected_items):
|
| 73 |
-
return gr.Dropdown.update(choices=selected_items, value=selected_items[0] if selected_items else None)
|
| 74 |
-
|
| 75 |
-
dish_list.change(fn=update_selected_dishes, inputs=dish_list, outputs=selected_dishes)
|
| 76 |
|
| 77 |
-
# Event: Show dish details when a dish is selected
|
| 78 |
-
|
| 79 |
-
|
| 80 |
|
| 81 |
return demo
|
| 82 |
|
|
|
|
| 42 |
gr.HTML("<h1 style='text-align: center;'>Biryani Hub Menu</h1>")
|
| 43 |
|
| 44 |
# Category Selection Buttons
|
| 45 |
+
gr.Markdown("### Select a Category")
|
| 46 |
with gr.Row():
|
| 47 |
all_button = gr.Button("ALL")
|
| 48 |
vegan_button = gr.Button("VEGAN")
|
| 49 |
halal_button = gr.Button("HALAL")
|
| 50 |
|
| 51 |
+
# Dish Dropdown (Dynamically updated)
|
| 52 |
+
gr.Markdown("### Select a Dish")
|
| 53 |
+
dish_dropdown = gr.Dropdown(label="Available Dishes", choices=filter_dishes("ALL"), value=None, interactive=True)
|
| 54 |
|
| 55 |
+
# Dish Details
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
gr.Markdown("### Dish Details")
|
| 57 |
dish_image = gr.Image(label="Dish Image", type="pil")
|
| 58 |
dish_description = gr.Textbox(label="Description", interactive=False)
|
|
|
|
| 60 |
dish_spice_level = gr.Textbox(label="Spice Level", interactive=False)
|
| 61 |
dish_portion_size = gr.Textbox(label="Portion Size", interactive=False)
|
| 62 |
|
| 63 |
+
# Event: Update dish list based on category buttons
|
| 64 |
+
all_button.click(fn=lambda: filter_dishes("ALL"), outputs=dish_dropdown)
|
| 65 |
+
vegan_button.click(fn=lambda: filter_dishes("VEGAN"), outputs=dish_dropdown)
|
| 66 |
+
halal_button.click(fn=lambda: filter_dishes("HALAL"), outputs=dish_dropdown)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
# Event: Show dish details when a dish is selected
|
| 69 |
+
dish_dropdown.change(fn=show_dish_details, inputs=dish_dropdown,
|
| 70 |
+
outputs=[dish_image, dish_description, dish_price, dish_spice_level, dish_portion_size])
|
| 71 |
|
| 72 |
return demo
|
| 73 |
|