Rammohan0504 commited on
Commit
4714bcf
·
verified ·
1 Parent(s): 1f6ab3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -21
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
- # Section 1: Menu 1 - Dish Names by Category
51
- gr.Markdown("### Select Items by Category")
52
- dish_list = gr.CheckboxGroup(label="Available Dishes", choices=filter_dishes("ALL"), interactive=True)
53
 
54
- # Section 2: Menu 2 - Selected Items
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 dish_list based on category buttons
67
- all_button.click(fn=lambda: filter_dishes("ALL"), outputs=dish_list)
68
- vegan_button.click(fn=lambda: filter_dishes("VEGAN"), outputs=dish_list)
69
- halal_button.click(fn=lambda: filter_dishes("HALAL"), outputs=dish_list)
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 from selected_dishes
78
- selected_dishes.change(fn=show_dish_details, inputs=selected_dishes,
79
- outputs=[dish_image, dish_description, dish_price, dish_spice_level, dish_portion_size])
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