From c21efa0c067e6d69586cd6e2b82841f350408c9b Mon Sep 17 00:00:00 2001 From: "houhan@gmail.com" Date: Tue, 24 Dec 2024 03:47:44 +0000 Subject: [PATCH] use form to improve load_settings --- code/Home.py | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/code/Home.py b/code/Home.py index d360c43..31b8ecb 100644 --- a/code/Home.py +++ b/code/Home.py @@ -532,32 +532,33 @@ def app(): # with col1: # -- 1. unit dataframe -- - cols = st.columns([2, 2, 4, 1]) + cols = st.columns([2, 4, 1]) cols[0].markdown(f'### Filter the sessions on the sidebar\n' f'##### {len(st.session_state.df_session_filtered)} sessions, ' f'{len(st.session_state.df_session_filtered.h2o.unique())} mice filtered') - - if_load_bpod_sessions = checkbox_wrapper_for_url_query( - st_prefix=cols[1], - label='Include old Bpod sessions (reload after change)', - key='if_load_bpod_sessions', - default=False, - ) - - if_load_docDB = checkbox_wrapper_for_url_query( - st_prefix=cols[2], - label='Load metadata from docDB (reload after change)', - key='if_load_docDB', - default=False, - ) - - with cols[1]: - if st.button(' Reload data ', type='primary'): - st.cache_data.clear() - init() - st.rerun() + with cols[1]: + with st.form(key='load_settings', clear_on_submit=False): + if_load_bpod_sessions = checkbox_wrapper_for_url_query( + st_prefix=st, + label='Include old Bpod sessions (reload after change)', + key='if_load_bpod_sessions', + default=False, + ) + if_load_docDB = checkbox_wrapper_for_url_query( + st_prefix=st, + label='Load metadata from docDB (reload after change)', + key='if_load_docDB', + default=False, + ) + + submitted = st.form_submit_button("Reload data! 🔄", type='primary') + if submitted: + st.cache_data.clear() + sync_session_state_to_URL() + init() + st.rerun() # Reload the page to apply the changes - table_height = slider_wrapper_for_url_query(st_prefix=cols[3], + table_height = slider_wrapper_for_url_query(st_prefix=cols[2], label='Table height', min_value=0, max_value=2000,