Everytime the selectbox option is selected the app is re-run

Hi, I am running my streamlit app in my local. I will mention my git repo link below. I am using login form to login in streamlit. I am logging in to a next page and I am using selectbox there. But when I select an option in the selectbox the app re-runs and the login page is visibile again. I tried st.cache but it is depricated. I am using Python 3.12.0 and streamlit version 1.28.2. Please help me resolve this.

Github link : https://github.com/suhashstudy/Git_task/tree/bc4ceeabcca42ae5a6e2778bdb3fd4c39b550bf5/Streamlit_code

Hi @Suhash

This is to expected as Streamlit reruns the app from top to bottom with every widget interaction. In order to prevent this, you can make use of session state variables so that variables assigned by widget interactions would be stored and shared across app reruns.

Please see the following Docs pages for details and code snippets:

Hope this helps!

Thank you @dataprofessor. It worked, really appreciate it.

1 Like

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