【问题标题】:Is there a way to change the placeholder text of a spinner in streamlit?有没有办法在流光中更改微调器的占位符文本?
【发布时间】:2020-11-21 10:51:24
【问题描述】:

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

我尝试过使用

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

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

【问题讨论】:

    标签: streamlit


    【解决方案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()
    

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

    【讨论】:

      猜你喜欢
      • 2020-11-11
      • 2015-08-20
      • 1970-01-01
      • 1970-01-01
      • 2021-07-10
      • 1970-01-01
      • 2016-10-08
      • 2021-05-21
      • 1970-01-01
      相关资源
      最近更新 更多