St.empty for images

Is there a way to refresh images, like it is possible with st.empty() at the beginning of a loop?

At the moment i can create a placeholder for a string with string = st.empy() at the beginning of my loop,
later in my loop i can make a RESTcall for example and fill this “string” and in the next iteration again.

With images or other objects you spam the screen, because they are all new created objects.

I want to do the same with images or even audio files, maybe something like the clear screen or clear cache that was possible in the earlier versions.

Hi @Bonian, welcome to the Streamlit community!

Yes, what you are asking is how st.empty is intended to work. However, you should have the st.empty container defined outside of the loop if you want to keep reusing the same position. Our documentation has a couple of examples:

Best,
Randy

1 Like

Oh, thanks! didnt notice that you made a new fast loading documentation in the last months. Great!
Therefore didnt notice that container example for st.empty, i think back then it was only a text string example. Cool stuff!

1 Like