Can't delete widget

We want to serve additional menus sequentially based on the selection from the options provided.
I’m using streamlit-option-menu. because selectbox can’t maintain the dropdown state, and radio can’t remove the button in front of it.

button to sequentially remove the child option_menu created by the button, but del doesn’t work.

from streamlit_option_menu import option_menu
def create_option_menu(key, header, data, on_change_callback):
selected_category = option_menu(None, [header] + list(data),
on_change=on_change_callback,
key=key
)
return selected_category

create option_menu and save to session

st.session_state[“selected_category”] = create_option_menu(‘category’, cfg.OPTION_CATEGORY, categories, on_change)

not change…

if st.button(“home”, key=‘btn_home’):
del st.session_state[“selected_type”]
st.rerun()`

I don’t know about streamlit-options-menu but what do you mean by the following:

…because selectbox can’t maintain the dropdown state, and radio can’t remove the button in front of it.

If you explain more about your situation and what wasn’t working before trying streamlit-option-menu I might be able to help.

If I’m guessing correctly, you might want to check out Widget behavior to understand more about widget statefulness, especially between pages.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.