St.button behaviour on start streamlit app server locally

Hello,

i’m just a beginner in streamlit and it seems if i have an problem with this simple statement:

if st.sidebar.button("Reindex "):
    st.error("reindex")

I thought this will run just on click, but it seems to run on every start … how can i prevent the button from running on startup? Thanks in advance and sorry for dumb question, but my search did not give me a good idea how to prevent. On top at least for me it seems the wrong behaviour, but maybe just for me :slight_smile:
Thanks again

Hi there, thanks for posting a question. I tested your example code locally on streamlit 1.23.1 with the following behavior:

  • Script start: “Reindex” button appears in side bar
  • Click “Reindex”
  • “reindex” error element appears in the main window.

Can you share the following information to help us figure out why you might be experiencing different behavior?

  • Streamlit version number
  • Command line arguments that you are using to start up streamlit
  • Can you clarify the behavior you observe when “it seems to run on every start”?

Cheers!

Now it needs at least 2 sorries… first for not being precisly and second… like 99% of the errors it was a very stupid “problem sitting on front of the computer” error… sorry again