MarcosRodrigo commited on
Commit
36dc00e
·
verified ·
1 Parent(s): e9e80c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -41
app.py CHANGED
@@ -116,66 +116,39 @@ def reset_selections():
116
  if menu == "Poll":
117
  st.title("Breakfast Poll Application")
118
 
119
- # Step 1: User's Name
120
  if st.session_state.step == 1:
121
  st.header("Step 1: Enter your name")
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.selected_drinks = [] # Initialize an empty list to store selected drinks
126
- st.session_state.selected_food = [] # Initialize an empty list to store selected food
127
  st.session_state.step = 2
128
 
129
- # Step 2: Select Drinks
130
- elif st.session_state.step == 2:
131
  st.header("Step 2: Select your drink(s)")
132
  drinks_options = [
133
  "Café con leche", "Colacao", "Descafeinado con leche", "Cortado",
134
  "Aguasusia", "Aguasusia susia", "Café descafeinado con leche desnatada",
135
  "Italiano", "Café con soja", "Té", "Manzanilla", "Nada"
136
  ]
 
 
 
 
137
 
138
- # Use st.multiselect to select drinks
139
- selected_drinks = st.multiselect("Choose your drinks:", drinks_options, key="drinks_multiselect")
140
-
141
- # Collapse the dropdown after selection by storing the value in session state
142
- if selected_drinks:
143
- st.session_state.selected_drinks = selected_drinks
144
- # st.experimental_rerun() # Force a rerun to collapse the dropdown
145
-
146
- # Show the "Next" button only if there are selected drinks
147
- if st.session_state.selected_drinks:
148
- if st.button("Next", key="step2_next"):
149
- st.session_state.step = 3
150
-
151
- # Step 3: Select Food
152
- elif st.session_state.step == 3:
153
  st.header("Step 3: Select your food(s)")
154
  food_options = [
155
  "Barrita con aceite", "Barrita con tomate", "Palmera de chocolate",
156
  "Palmera de chocolate blanco", "Yogurt", "Pincho de tortilla", "Nada"
157
  ]
158
-
159
- # Use st.multiselect to select food
160
- selected_food = st.multiselect("Choose your food:", food_options, key="food_multiselect")
161
-
162
- # Collapse the dropdown after selection by storing the value in session state
163
- if selected_food:
164
- st.session_state.selected_food = selected_food
165
- # st.experimental_rerun() # Force a rerun to collapse the dropdown
166
-
167
- # Show the "Save Selections" button only if there is selected food
168
- if st.session_state.selected_food:
169
- if st.button("Save Selections", key="save_selections"):
170
- st.session_state.current_selections[-1]["Food"] = st.session_state.selected_food
171
- df = pd.DataFrame(st.session_state.current_selections)
172
- save_current_selection_to_file(df)
173
- upload_temp_file_to_repo()
174
- st.success(f"Selections saved for {st.session_state.users[-1]}!")
175
- st.session_state.step = 1 # Reset to step 1 for the next user
176
- st.session_state.selected_drinks = [] # Reset the drinks selection
177
- st.session_state.selected_food = [] # Reset the food selection
178
-
179
  # "Current" view to display the current summary of all users' selections and submit to history
180
  elif menu == "Current":
181
  st.title("Current Selections of All Users")
 
116
  if menu == "Poll":
117
  st.title("Breakfast Poll Application")
118
 
 
119
  if st.session_state.step == 1:
120
  st.header("Step 1: Enter your name")
121
  name = st.text_input("Name:")
122
  if st.button("Next", key="step1_next") and name:
123
  st.session_state.users.append(name)
 
 
124
  st.session_state.step = 2
125
 
126
+ if st.session_state.step == 2:
 
127
  st.header("Step 2: Select your drink(s)")
128
  drinks_options = [
129
  "Café con leche", "Colacao", "Descafeinado con leche", "Cortado",
130
  "Aguasusia", "Aguasusia susia", "Café descafeinado con leche desnatada",
131
  "Italiano", "Café con soja", "Té", "Manzanilla", "Nada"
132
  ]
133
+ selected_drinks = st.multiselect("Choose your drinks:", drinks_options)
134
+ if st.button("Next", key="step2_next") and selected_drinks:
135
+ st.session_state.current_selections.append({"Name": st.session_state.users[-1], "Drinks": selected_drinks})
136
+ st.session_state.step = 3
137
 
138
+ if st.session_state.step == 3:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  st.header("Step 3: Select your food(s)")
140
  food_options = [
141
  "Barrita con aceite", "Barrita con tomate", "Palmera de chocolate",
142
  "Palmera de chocolate blanco", "Yogurt", "Pincho de tortilla", "Nada"
143
  ]
144
+ selected_food = st.multiselect("Choose your food:", food_options)
145
+ if st.button("Save Selections", key="save_selections") and selected_food:
146
+ st.session_state.current_selections[-1]["Food"] = selected_food
147
+ df = pd.DataFrame(st.session_state.current_selections)
148
+ save_current_selection_to_file(df)
149
+ upload_temp_file_to_repo()
150
+ st.success(f"Selections saved for {st.session_state.users[-1]}!")
151
+ st.session_state.step = 1
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  # "Current" view to display the current summary of all users' selections and submit to history
153
  elif menu == "Current":
154
  st.title("Current Selections of All Users")