Selectbox on Streamlit

I need help with a Streamlit app where selecting an option in one select box should clear all other select boxes and make them empty.
Provide code and screenshot


load_data_flag = False
missing_flag =  False
corr_flag = False
    
if load_data_button:
      st.success("Data load successfully")
      st.dataframe(df, width=1200, height=500)
      load_data_flag = True
        chosen_plot = None
        technical_button = None
        yw_button = None
        forecast_button = None
        
  if corr_button and not load_data_flag:
       corr_flag =True
       chosen_plot = None
       technical_button = None
       yw_button = None
        forecast_button = None
        plot_correlation(df, selected_columns)

    if missing_button and not load_data_flag:
        missing_flag = True
        chosen_plot = None
        yw_button = None
        technical_button = None
        forecast_button = None
        missing(df)
    chosen_plot = st.sidebar.selectbox("Choose distribution", ["", "Day", "Month", "Quarter", "Year"])
    yw_button = st.sidebar.selectbox("Year-Wise Time Series Plot",["","Low and High","Adj Close and Close"])
    technical_button = st.sidebar.selectbox("Technical Indicators",["","Adj Close versus Daily Return by Year","Differences"])
    forecast_button = st.sidebar.selectbox("Choose Forecasting Model", ["", "Linear Regression","Lasso Regression"],key="forecast_button")

    
    model_name = st.sidebar.selectbox("Choose Machine Learning Model", ["","Support Vector Machine (SVC)","Logistic Regression"],key="model_button")
    if chosen_plot and not load_data_flag and not missing_flag and not corr_flag:
        if chosen_plot == "Day":
            plot_pie_bar_chart(df_dummy, "Day")
        elif chosen_plot == "Month":
            plot_pie_bar_chart(df_dummy, "Month")
        elif chosen_plot == "Quarter":
            plot_pie_bar_chart(df_dummy, "Quarter")            
        elif chosen_plot == "Year":
            plot_pie_bar_chart(df_dummy, "Year")
    elif  yw_button and not load_data_flag and not missing_flag and not corr_flag:
        if yw_button == "Low and High":
            plot_low_high_over_year(df_dummy, 2019)
            plot_low_high_over_year(df_dummy, 2020)

Hi @Truong6886

It seems there are several nested widgets which may cause the app to re-run. To resolve this I would recommend to refactor the code by making use of session state and callback functions. For example, you can package the condition statements with True, None, etc. as callback functions that is called upon via the on_click parameter of st.button().

Here are Docs page on session state and callback function:

Hope this helps!