James McCool commited on
Commit
16aefb8
·
1 Parent(s): 354d2df

Implement enhanced reset functionality in app.py

Browse files

- Introduced a dedicated reset button that clears specific session state variables related to player selection, providing users with a streamlined way to reset their choices.
- Improved the layout by organizing the clear and reset buttons into separate columns for better UI spacing and usability.

Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -230,8 +230,26 @@ with tab2:
230
  st.session_state['field_stack_frame'] = create_stack_exposures(working_df)
231
 
232
  with st.expander("Info and filters"):
233
- if st.button('Clear data', key='reset3'):
234
- st.session_state.clear()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  with st.form(key='filter_form'):
236
  users_var, entries_var, stack_var, stack_size_var, player_var = st.columns(5)
237
  with users_var:
@@ -251,26 +269,7 @@ with tab2:
251
  unique_players = [p for p in unique_players if p != 'nan'] # Remove any NaN values
252
  player_parse_var = st.selectbox("Do you want to view lineups with specific player(s)?", ['All', 'Specific'], key = 'player_parse_var')
253
  player_names = st.multiselect("Select players", options=unique_players, default=[], key = 'player_names')
254
- submit_col, reset_col, blank_col = st.columns([1, 1, 12])
255
- with submit_col:
256
- submitted = st.form_submit_button("Submit")
257
- with reset_col:
258
- reset = st.form_submit_button("Reset")
259
- if reset:
260
- entry_names = []
261
- low_entries_var = 1
262
- high_entries_var = 150
263
- stack_names = []
264
- stack_size_names = []
265
- player_names = []
266
- player_parse_var = 'All'
267
- stack_parse_var = 'All'
268
- stack_size_parse_var = 'All'
269
- entry_parse_var = 'All'
270
- for each_var in [entry_names, stack_names, stack_size_names, player_names]:
271
- if each_var in st.session_state:
272
- del st.session_state[each_var]
273
-
274
  if submitted:
275
  if 'player_frame' in st.session_state:
276
  del st.session_state['player_frame']
 
230
  st.session_state['field_stack_frame'] = create_stack_exposures(working_df)
231
 
232
  with st.expander("Info and filters"):
233
+ clear_col, reset_col, blank_col = st.columns([1, 1, 12])
234
+ with clear_col:
235
+ if st.button('Clear data', key='reset3'):
236
+ st.session_state.clear()
237
+ with reset_col:
238
+ reset = st.form_submit_button("Reset")
239
+ if reset:
240
+ entry_names = []
241
+ low_entries_var = 1
242
+ high_entries_var = 150
243
+ stack_names = []
244
+ stack_size_names = []
245
+ player_names = []
246
+ player_parse_var = 'All'
247
+ stack_parse_var = 'All'
248
+ stack_size_parse_var = 'All'
249
+ entry_parse_var = 'All'
250
+ for each_var in [entry_names, stack_names, stack_size_names, player_names]:
251
+ if each_var in st.session_state:
252
+ del st.session_state[each_var]
253
  with st.form(key='filter_form'):
254
  users_var, entries_var, stack_var, stack_size_var, player_var = st.columns(5)
255
  with users_var:
 
269
  unique_players = [p for p in unique_players if p != 'nan'] # Remove any NaN values
270
  player_parse_var = st.selectbox("Do you want to view lineups with specific player(s)?", ['All', 'Specific'], key = 'player_parse_var')
271
  player_names = st.multiselect("Select players", options=unique_players, default=[], key = 'player_names')
272
+ submitted = st.form_submit_button("Submit")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  if submitted:
274
  if 'player_frame' in st.session_state:
275
  del st.session_state['player_frame']