I would like to put all my loading messages in one set location.
My app has a few expanders, utilizes the sidebar, and makes great use of caching via
st.experimental_memo. Often times, spinners and messages get lost because they appear in the app in the order the components are called.
I’ve tried to reserve a spot in the sidebar where all the temporary messages would be shown and disappear once the function finishes.
loading_placeholder = st.empty() # Some code with loading_placeholder.spinner("Calculating"): # Function that takes some time
This is not currently possible and when run is met with the following error:
streamlit.errors.StreamlitAPIException: Method \spinner()` does not exist for `DeltaGenerator` objects. Did you mean `st.spinner()`?`
We can acheive the wanted behavior with the following:
loading_placeholder = st.empty() # Some code with loading_placeholder: with loading_placeholder.spinner("Calculating"): # Function that takes some time
This works, but requires an extra line and an extra indent. Is there a better / shorter way to acheive this?