Suppose I have many widgets in a section of my code, e.g. setting, and I want to create a button to reset all widgets in such section to their default value.
I know how to do by using a callback function and changing each state of the widget manually to its default value in the callback function. However, I want to do it in a more systematic way, to avoid having to reset each widget manually. Each widget in such section has a key starting with setting_, so I would expect something like
def clear_settings():
for state in st.session_state:
if state.startswith('setting_'):
del st.session_state[state]
st.button("**Clear all filters**", on_click=clear_settings)
to work. This does indeed reset the values of all the filters to default value, but visually the filters do not refresh, and still display the previous value. How do I fix this? rerunning the session does not work either.