Hi, I have a problem when creating sidebar button. When I click analysis, it will show “Data loading” and “Visualizations” button. But when I click “Data loading” or"Visualizations" button, it will return to “Analysis” button. I have try to use session_state, but it doesn’t work. Could anyone help me solve this problem? Thank you in advance!
if st.button('Analysis'):
if sidebar.button("Data loading"):
show_basic_statistics()
elif sidebar.button("Visualizations"):
selected_subcontent = sidebar.radio("Select:", ["OptionA", "OptionB"])
if selected_subcontent == "OptionA" :
st.header('OptionA')
opt = ["Option1", "Option2", "Option3"]
option = st.selectbox("Select an option", opt)
if option == Option1":
Using Session_state:
if "Data loading" not in st.session_state:
st.session_state["Data loading"] = False
if "Visualizations" not in st.session_state:
st.session_state["Visualizations"] = False
if st.button('Analysis'):
if sidebar.button("Data loading"):
st.session_state["Data loading"] = True
show_basic_statistics()
show_data_preview()
if st.session_state["Visualizations"]:
if sidebar.button(" Visualizations"):
st.session_state["Visualizations"] = True
selected_subcontent = sidebar.radio("Select:", ["OptionA", "OptionB"])