有没有办法以流线方式更改微调框的占位符文本?

时间:2020-07-31 15:04:14

标签: streamlit

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

enter image description here

我尝试使用

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

,但是它只是在上面带有“提取措施”的警告中添加了新的警告。有没有办法只更改文本“ Running function_name(…)”?

1 个答案:

答案 0 :(得分:1)

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

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