khanhlinhnguyen commited on
Commit
b138bbc
·
verified ·
1 Parent(s): 8eaa4f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -270,13 +270,26 @@ def show_menu(section):
270
  """
271
  return html_output
272
 
273
- # Gradio app
274
- demo = gr.Interface(
275
- fn=show_menu,
276
- inputs=gr.Dropdown(list(menu.keys()), label="Select a Menu Section"),
277
- outputs=gr.HTML(),
278
- title="🍜🥢EAT EAT Cafe & Bistro",
279
- description="Choose a section to explore dishes with images, descriptions and prices."
280
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
  demo.launch()
 
270
  """
271
  return html_output
272
 
273
+ # Function to handle button click
274
+ def confirm_selection():
275
+ return "✅ Thank you! Your selection has been noted."
276
+
277
+ # Gradio Blocks version with button
278
+ with gr.Blocks() as demo:
279
+ gr.Markdown("# 🍜🥢 EAT EAT Cafe & Bistro")
280
+ gr.Markdown("Choose a section to explore dishes with images, descriptions, and prices.")
281
+
282
+ section_dropdown = gr.Dropdown(list(menu.keys()), label="Select a Menu Section")
283
+ menu_output = gr.HTML()
284
+ confirm_msg = gr.Textbox(visible=False)
285
+
286
+ section_dropdown.change(fn=show_menu, inputs=section_dropdown, outputs=menu_output)
287
+
288
+ confirm_button = gr.Button("✅ I have made my selection")
289
+ confirm_button.click(fn=confirm_selection, inputs=None, outputs=confirm_msg)
290
+ confirm_msg.render()
291
+
292
+ # Layout
293
+ menu_output.render()
294
 
295
  demo.launch()