Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -122,6 +122,7 @@ if menu == "Poll":
|
|
122 |
name = st.text_input("Name:")
|
123 |
if st.button("Next", key="step1_next") and name:
|
124 |
st.session_state.users.append(name)
|
|
|
125 |
st.session_state.step = 2
|
126 |
|
127 |
# Step 2: Select Drinks
|
@@ -133,12 +134,19 @@ if menu == "Poll":
|
|
133 |
"Italiano", "Café con soja", "Té", "Manzanilla", "Nada"
|
134 |
]
|
135 |
|
136 |
-
#
|
137 |
-
|
138 |
-
selected_drinks = st.multiselect("", drinks_options)
|
|
|
|
|
139 |
|
140 |
-
if st.
|
|
|
|
|
|
|
|
|
141 |
st.session_state.current_selections.append({"Name": st.session_state.users[-1], "Drinks": selected_drinks})
|
|
|
142 |
st.session_state.step = 3
|
143 |
|
144 |
# Step 3: Select Food
|
@@ -149,11 +157,17 @@ if menu == "Poll":
|
|
149 |
"Palmera de chocolate blanco", "Yogurt", "Pincho de tortilla", "Nada"
|
150 |
]
|
151 |
|
152 |
-
#
|
153 |
-
|
154 |
-
selected_food = st.multiselect("", food_options)
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
if st.button("Save Selections", key="save_selections") and
|
157 |
st.session_state.current_selections[-1]["Food"] = selected_food
|
158 |
df = pd.DataFrame(st.session_state.current_selections)
|
159 |
save_current_selection_to_file(df)
|
|
|
122 |
name = st.text_input("Name:")
|
123 |
if st.button("Next", key="step1_next") and name:
|
124 |
st.session_state.users.append(name)
|
125 |
+
st.session_state.show_drinks_dropdown = True # Initialize the dropdown state for Step 2
|
126 |
st.session_state.step = 2
|
127 |
|
128 |
# Step 2: Select Drinks
|
|
|
134 |
"Italiano", "Café con soja", "Té", "Manzanilla", "Nada"
|
135 |
]
|
136 |
|
137 |
+
# Control visibility of the dropdown using session state
|
138 |
+
if st.session_state.get("show_drinks_dropdown", True):
|
139 |
+
selected_drinks = st.multiselect("Choose your drinks:", drinks_options)
|
140 |
+
else:
|
141 |
+
st.write("Drinks selected successfully!")
|
142 |
|
143 |
+
if st.session_state.get("show_drinks_dropdown", True) and selected_drinks:
|
144 |
+
# If drinks are selected, hide the dropdown and show confirmation text
|
145 |
+
st.session_state.show_drinks_dropdown = False
|
146 |
+
|
147 |
+
if st.button("Next", key="step2_next") and not st.session_state.get("show_drinks_dropdown", True):
|
148 |
st.session_state.current_selections.append({"Name": st.session_state.users[-1], "Drinks": selected_drinks})
|
149 |
+
st.session_state.show_food_dropdown = True # Initialize the dropdown state for Step 3
|
150 |
st.session_state.step = 3
|
151 |
|
152 |
# Step 3: Select Food
|
|
|
157 |
"Palmera de chocolate blanco", "Yogurt", "Pincho de tortilla", "Nada"
|
158 |
]
|
159 |
|
160 |
+
# Control visibility of the dropdown using session state
|
161 |
+
if st.session_state.get("show_food_dropdown", True):
|
162 |
+
selected_food = st.multiselect("Choose your food:", food_options)
|
163 |
+
else:
|
164 |
+
st.write("Food selected successfully!")
|
165 |
+
|
166 |
+
if st.session_state.get("show_food_dropdown", True) and selected_food:
|
167 |
+
# If food is selected, hide the dropdown and show confirmation text
|
168 |
+
st.session_state.show_food_dropdown = False
|
169 |
|
170 |
+
if st.button("Save Selections", key="save_selections") and not st.session_state.get("show_food_dropdown", True):
|
171 |
st.session_state.current_selections[-1]["Food"] = selected_food
|
172 |
df = pd.DataFrame(st.session_state.current_selections)
|
173 |
save_current_selection_to_file(df)
|