Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,28 @@ import gradio as gr
|
|
2 |
|
3 |
# Define menu items
|
4 |
menu_items = [
|
5 |
-
{
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
]
|
10 |
|
|
|
|
|
|
|
|
|
11 |
# Create the Gradio interface
|
12 |
def render_menu():
|
13 |
with gr.Blocks(css="""
|
@@ -20,6 +36,10 @@ def render_menu():
|
|
20 |
font-weight: bold;
|
21 |
text-align: center;
|
22 |
background-color: #fff;
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
.menu-container {
|
25 |
margin-top: 20px;
|
@@ -27,10 +47,25 @@ def render_menu():
|
|
27 |
""") as demo:
|
28 |
gr.Markdown("# Menu")
|
29 |
|
|
|
|
|
|
|
|
|
30 |
with gr.Column(elem_id="menu-container"):
|
31 |
for item in menu_items:
|
32 |
-
with gr.Row(elem_classes=["menu-item"]):
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
return demo
|
36 |
|
|
|
2 |
|
3 |
# Define menu items
|
4 |
menu_items = [
|
5 |
+
{
|
6 |
+
"name": "Chicken Butter Masala",
|
7 |
+
"description": "A creamy and rich butter chicken dish.",
|
8 |
+
},
|
9 |
+
{
|
10 |
+
"name": "Chicken Biryani",
|
11 |
+
"description": "Aromatic rice cooked with chicken and spices.",
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "Dosa",
|
15 |
+
"description": "A crispy South Indian crepe served with chutney.",
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"name": "Aloo Curry",
|
19 |
+
"description": "Potatoes cooked in a spicy curry sauce.",
|
20 |
+
},
|
21 |
]
|
22 |
|
23 |
+
# Function to handle the popup
|
24 |
+
def show_popup(item_name, item_description):
|
25 |
+
return f"### {item_name}\n\n{item_description}"
|
26 |
+
|
27 |
# Create the Gradio interface
|
28 |
def render_menu():
|
29 |
with gr.Blocks(css="""
|
|
|
36 |
font-weight: bold;
|
37 |
text-align: center;
|
38 |
background-color: #fff;
|
39 |
+
cursor: pointer;
|
40 |
+
}
|
41 |
+
.menu-item:hover {
|
42 |
+
background-color: #f0f0f0;
|
43 |
}
|
44 |
.menu-container {
|
45 |
margin-top: 20px;
|
|
|
47 |
""") as demo:
|
48 |
gr.Markdown("# Menu")
|
49 |
|
50 |
+
# Popup display area
|
51 |
+
popup_output = gr.Markdown("### Select an item to view details.")
|
52 |
+
|
53 |
+
# Display the menu items
|
54 |
with gr.Column(elem_id="menu-container"):
|
55 |
for item in menu_items:
|
56 |
+
with gr.Row(elem_classes=["menu-item"]):
|
57 |
+
# Display item name with a clickable action
|
58 |
+
button = gr.Button(item["name"], elem_id=f"{item['name']}-button")
|
59 |
+
button.click(
|
60 |
+
fn=show_popup,
|
61 |
+
inputs=[],
|
62 |
+
outputs=popup_output,
|
63 |
+
_js=f"() => ['{item['name']}', '{item['description']}']"
|
64 |
+
)
|
65 |
+
|
66 |
+
# Popup section to show details
|
67 |
+
gr.Markdown("## Selected Item Details")
|
68 |
+
gr.Box(popup_output)
|
69 |
|
70 |
return demo
|
71 |
|