How to avoid screen Reset

Hello,

I am building an app where once I press the button, it shows me the radio buttons with the options and the processed data on the dashboard, but as soon as I change the radio button option everything disappears. Ideally, I want it to show everything until I press the button again. I understand I can save the value of the selected radio button in session state but how to avoid the reset of the page?

The minimal code I can come up with is

import streamlit as st
import numpy as np
import pandas as pd

def main():

    next_button = st.button("Process", key='next_process_whatif')

    if st.session_state.next_process_whatif:
        # ------------------------------------------
        choose_pred_lst = ['XZ']
        for _dx in range(3):
            _dx += 1
            choose_pred_lst.append("YZ " + str(_dx))

        x = st.radio('', choose_pred_lst, key="radio_select_whatif")
        # ------------------------------------------
        st.dataframe(pd.DataFrame(np.random.randint(0, 100, size=(100, 4)), columns=list('ABCD')))

main()

Sounds like streamlit.form() is the solution: API reference — Streamlit 0.85.0 documentation

Thank you @ksxx , Worked for my app :slight_smile: