Suppress rerunning of function (only for first value initialisation)

Hi,

I created a streamlit app with several input fields like number inputs and and selectboxes.

When I run the app for the first time all number inputs have a initial value.
a = st.number_input(“value a”,value=ini_a)

I also created a button to read data from an external source. When this button is pressed the value a is set to the value from the external source.

Now when I change another nuber field all number fields are set to the initial value but I want to keep the manually set value.

I tried to use @cache but it does not work because it is not a real calculation and I just want to initialize the values once.

Do you have an idea how to implement something like this?

Thanks for your help.

Hi @Specht , see if session state can help you (refer Streamlit documentation).

Cheers

Thanks Shawn, that helped me a lot and solved my problem