Avoid fading output during longer background activity

Dear all!

I wrote an app to display images from a 2D detector. I use the st.experimental_rerun() function to this continuously. When using longer exposure times (seconds) the image displayed from the previous run fades as do some of the other components (I added for setting up acquisition parameters).

Is there a way to avoid this, i.e. at least the image remains displayed with the original contrasts until being replaced by the new one?

Thanks a lot in advance and for the great streamlit!

Markus

Digging further through the discussions here, I found that above topic can help me, by making components of my streamlit app be run as co-routines controlled(?) by asyncio.

Still, I shall appreciate any comment on my initial post. :slight_smile:

Thank you!
Markus

Hello @w-markus !

I don’t think it is possible to control the fading out for now. Maybe you’ll have better luck by putting the image in a placeholder and emptying it before running the rerun?

# beware, not tested code :) 
image_placeholder = st.empty()
image_placeholder.image(t)

...
if st.button("Rerun"):
    image_placeholder.empty()
    st.experimental_rerun()

Fanilo

Hello @andfanilo!
Thanks a lot, but unfortunately this does not work, as wished.

The image disappears and other components shift into the emptied space. During the time to get the next image, things (e.g. some st.write() output) fade and than the image reappears.

Markus