Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,25 +128,34 @@ def create_interface():
|
|
| 128 |
protein_target = gr.Number(label="Target Protein (g)", value=25)
|
| 129 |
cost_limit = gr.Number(label="Maximum Cost (₹)", value=300)
|
| 130 |
|
| 131 |
-
|
| 132 |
optimize_button = gr.Button("Optimize")
|
| 133 |
|
| 134 |
dishes_output = gr.Markdown(label="Available Dishes")
|
| 135 |
optimization_output = gr.Markdown(label="Optimization Results")
|
| 136 |
|
| 137 |
-
# Function to
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
# Function to handle optimization
|
| 142 |
def run_optimization(city, target_calories, target_protein, max_cost):
|
| 143 |
return optimize_nutrition_in_city(city, target_calories, target_protein, max_cost)
|
| 144 |
|
| 145 |
-
|
| 146 |
optimize_button.click(fn=run_optimization, inputs=[city_selector, energy_target, protein_target, cost_limit], outputs=optimization_output)
|
| 147 |
|
| 148 |
gr.Row([city_selector, energy_target, protein_target, cost_limit])
|
| 149 |
-
gr.Row(
|
| 150 |
gr.Row(dishes_output)
|
| 151 |
gr.Row(optimization_output)
|
| 152 |
|
|
|
|
| 128 |
protein_target = gr.Number(label="Target Protein (g)", value=25)
|
| 129 |
cost_limit = gr.Number(label="Maximum Cost (₹)", value=300)
|
| 130 |
|
| 131 |
+
toggle_dishes_button = gr.Button("Display Dishes")
|
| 132 |
optimize_button = gr.Button("Optimize")
|
| 133 |
|
| 134 |
dishes_output = gr.Markdown(label="Available Dishes")
|
| 135 |
optimization_output = gr.Markdown(label="Optimization Results")
|
| 136 |
|
| 137 |
+
# Function to toggle the display of dishes
|
| 138 |
+
dishes_visible = False
|
| 139 |
+
|
| 140 |
+
def toggle_dishes(city):
|
| 141 |
+
nonlocal dishes_visible
|
| 142 |
+
dishes_visible = not dishes_visible
|
| 143 |
+
if dishes_visible:
|
| 144 |
+
toggle_dishes_button.label = "Hide Dishes"
|
| 145 |
+
return display_dishes_in_city(city)
|
| 146 |
+
else:
|
| 147 |
+
toggle_dishes_button.label = "Display Dishes"
|
| 148 |
+
return ""
|
| 149 |
|
| 150 |
# Function to handle optimization
|
| 151 |
def run_optimization(city, target_calories, target_protein, max_cost):
|
| 152 |
return optimize_nutrition_in_city(city, target_calories, target_protein, max_cost)
|
| 153 |
|
| 154 |
+
toggle_dishes_button.click(fn=toggle_dishes, inputs=[city_selector], outputs=dishes_output)
|
| 155 |
optimize_button.click(fn=run_optimization, inputs=[city_selector, energy_target, protein_target, cost_limit], outputs=optimization_output)
|
| 156 |
|
| 157 |
gr.Row([city_selector, energy_target, protein_target, cost_limit])
|
| 158 |
+
gr.Row(toggle_dishes_button, optimize_button)
|
| 159 |
gr.Row(dishes_output)
|
| 160 |
gr.Row(optimization_output)
|
| 161 |
|