【问题标题】:Streamlit reset results on input changeStreamlit 输入更改时的重置结果
【发布时间】:2020-09-30 12:14:53
【问题描述】:

我的问题与下面的 url 非常相似: https://discuss.streamlit.io/t/the-button-inside-a-button-seems-to-reset-the-whole-app-why/1051

我有一个按钮,可以根据用户输入的特定值加载滑块和输入。这个想法是,每当我更改滑块或对输入进行更改时,都会导致页面重置。

网址上描述的解决方案将不起作用。它会给出以下错误:

AttributeError: type object 'SessionState' has no attribute 'get'

【问题讨论】:

    标签: python button onchange reset streamlit


    【解决方案1】:

    如果您使用的是 streamlit 0.65,则需要修复 SessionState.py(至少是我拥有的版本):

    适用于 streamlit 0.64(第 87 行)

    (not hasattr(s, '_main_dg') and s.enqueue == ctx.enqueue)
    

    在 streamlit 0.65 中工作(注意 _enqueue

    (not hasattr(s, '_main_dg') and s.enqueue == ctx._enqueue)
    

    【讨论】:

    • 作为旁注,我切换到使用查询参数来存储应用程序状态。请参阅 st.experimental_get_query_params()st.experimental_set_query_params() 上的文档。它更适合存储应用程序状态。
    猜你喜欢
    • 2018-01-11
    • 2017-09-23
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多