Updating only certain content on page

Hey everybody, i have this problem:

i am facing toghether with some schoolmates a Data Science project where we made a market analysis tool; available to see here:


the problem is that once you, for example, select a different vendor to be displayed of the map down below, all the statistics from the previous search disappear.

The only case i’d like that to happen is indeed when pressing search once more.

the code is 548 lines i don’t know if it’d be appropriate to paste here.

Thanks in advance for the help!

Hi @castoldie , Welcome to the Streamlit Community Forum !

Thank you for sharing the app here, it’s really a nice app and wish you guys the best!

Best possible guess would be, since Streamlit runs linearly from the very top, the app reruns and therefore all your stats disappears, unless you click the search button again.

  • An easy (not ideal) quick fix would be, to change your submit button to a checkbox st.checkbox. Which will maintain the checked ‘ON’ state for the app.
  • Other possible workaround can be, to control the state of the search button using SessionState, [ st.session_state ]
  • Otherwise, wrapping up the computing part of your code, within a single function may do the trick with usage of st.experimental_memo or st.cache syntax. Do refer to the doc.

The above workarounds may not be valid, if it’s not the case within your app. You can always share the link of your code or link of your repo, if it’s fine for you to be public.

Let me know.

1 Like

the checkbox is working like a charm so far! We’ll see if we can further refine the interface.
Thank you!

1 Like