Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -46,28 +46,26 @@ def filter_menu(preference):
|
|
46 |
|
47 |
# Gradio app definition
|
48 |
def app():
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
# Layout definition
|
63 |
-
demo = gr.Interface(
|
64 |
-
fn=None,
|
65 |
-
inputs=[selected_preference],
|
66 |
-
outputs=[menu_output],
|
67 |
-
live=True,
|
68 |
-
title="Dynamic Menu with Preferences",
|
69 |
-
theme="default",
|
70 |
-
)
|
71 |
return demo
|
72 |
|
73 |
# Run the app
|
|
|
46 |
|
47 |
# Gradio app definition
|
48 |
def app():
|
49 |
+
with gr.Blocks(title="Dynamic Menu with Preferences") as demo:
|
50 |
+
# Radio button for selecting preference
|
51 |
+
selected_preference = gr.Radio(
|
52 |
+
choices=["All", "Vegan", "Halal", "Guilt-Free"],
|
53 |
+
value="All",
|
54 |
+
label="Choose a Preference",
|
55 |
+
)
|
56 |
|
57 |
+
# Output area for menu items
|
58 |
+
menu_output = gr.HTML(value=filter_menu("All"))
|
59 |
|
60 |
+
# Define interactivity
|
61 |
+
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|
62 |
+
|
63 |
+
# Layout
|
64 |
+
gr.Markdown("## Dynamic Menu with Preferences")
|
65 |
+
with gr.Row():
|
66 |
+
selected_preference.render()
|
67 |
+
menu_output.render()
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
return demo
|
70 |
|
71 |
# Run the app
|