有没有办法在 Streamlit 中更改微调器的占位符文本?

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

我想更改调用函数时显示的占位符文本:

我试过使用

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

但它只是在上面添加了一个带有“获取措施”的新警告。有没有办法只更改文本“运行 function_name(…)”?

Streamlit's forum 上找到了一种方法:

@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()

只需在 st.cache() 装饰器中添加 show_spinner=False 即可删除警告。然后,使用 with st.spinner(text="Fetching measures").

添加您自己的警告