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

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