Is there a way to change the placeholder text of a spinner?

I would like to change the placeholder text displayed when calling a function:

I tried using

with st.spinner(text="Fetching measures"):
        measures = fetch_measures(userid, start_ts, end_ts)

but it just adds a new warning above with “Fetching measures”. Is there a way to just change the text “Running function_name(…)”?

Hi vinzee,

I am not sure there is a beautiful solution to this, but you can disable the ‘original Running fetch_measures(…)’ by adding the show_spinner=False option on the cache decorator.

@st.cache(show_spinner=False)
def fetch_measures(x,y,z):
    #do stuff

and then you can use your solution using with st.spinner(text="Fetching measures")

5 Likes

Hi PeterT and vinzee
Can you give me an example of your code?? I’m having trouble after running @st.cache(show_spinner=False)

Hi Jose,

I did it like this:

@st.cache(show_spinner=False)
def fetch_measures():
    # do stuff
    time.sleep(10)


def main():
    with st.spinner(text="Fetching measures"):
        measures = fetch_measures()

if __name__ == "__main__":
    main()
4 Likes

Hello all,

I am trying to hide the st.cache spinner by setting show_spinner=False as @PeterT and @vinzee showed above, but it doesn’t seem to have any effect - I still get the ‘running…’ message when the function is first executed.

I am using Streamlit v0.82.0 - is it perhaps a bug in this version, or am I doing something wrong?

Hi,

It would be helpful if you could share an example of your code :slight_smile: Just to check, the “running…” message you see is it the one in the top right corner or the one in a yellow box?

Hi Peter,

I just added the decorator:
@st.cache(show_spinner=False)
to the function I wanted to cache. I am indeed referring to the ‘running …’ message in the yellow box still persisting.

Perhaps I should also mention I am running streamlit in a Linux environment.

I’m afraid I have no clue as to what could be causing this other than a potential logical error in the code :confused:

Hi PeterT, you are completely right - turns out I was confusing two functions with similar names, and I never added the show_spinner=False argument to cache for this particular function!

Thanks for responding, apologies for the human error!

2 Likes