Streamlit Version 1.50.0
Python 3
The app in question is running on an SBC, but I am networked with it and running the app my Mac.
This is a more general “flow” question…
I am new to Streamlit, and the app I am writing keeps running into greyed out elements being displayed.
I have taken time to read the docs (fundamentals section, and concepts section ), plus I have been searching the forum to try and figure out what I am doing wrong.
I am using “stages” to try and show different things on the screen at different times.
In stage 0, I’m displaying only button.
In stage 1, I’m displaying an image, a form (with a form button) plus another separate button outside the form.
I am using session_state to manage the “stage”, and each button updates session state.
The program goes like this:
if st.session_state.stage == 0:
with st.container():
st.button(“Take Picture”, on_click=create_data, key=“take_pic”):
if st.session_state.stage == 1:
with st.container():
st.image(st.session_state.current_image) # Display Picture
with st.form('item_form'):
…form fields
st.form_submit_button("Save to Database", on_click=save_to_db)
st.button("Reset Item", on_click=reset, key="reset_item")
The on_click functions do certain tasks, like taking a picture and making a single LLM call to analyze the picture PLUS they all change the session_state.stage
My issue is that I keep getting greyed out widgets sticking around.
At first it was the form, but using a container fixed that. Now it is the buttons. They just will not go away - after pressed, they stick around greyed out. My first button is weird - the first time I press it, it does not grey out - works like a charm. The second time it is pressed, it sticks around greyed out below the other widgets.
Maybe I am missing something on how to correctly develop an app with Streamlit? I understand that the entire app gets rerun every time a widget is interacted with, and when I plan out the stages, I “feel” like I am thinking through it correctly, but any general thoughts or tips would be much appreciated.
Here is the main file in the repo.