gpt4 book ai didi

python - 在绘图破折号中更新回调之外的应用程序状态

转载 作者:行者123 更新时间:2023-12-02 09:51:08 26 4
gpt4 key购买 nike

我正在编写一个plotly Dash应用程序,我最初没有数据库访问权限,因此我需要等待数据库连接,然后才能设置初始应用程序状态。

因此,我想运行一个稍后设置应用程序状态的函数,但设置状态的唯一方法似乎是使用 @app.callback() 装饰器,但问题是它们需要在触发之前观看属性或状态变量,但就我而言,我没有观看 Dash 应用程序的一部分,而是观看外部内容。

如何在 Dash 中执行此操作?

例如:

app = Dash(routes_pathname_prefix='/dash/trend/')

app.layout = html.Div(children=[
dcc.Dropdown(
options=get_field_options(),
id='field_select',
multi=True,
)
])

@app.callback(
dash.dependencies.Output('field_select', 'options'),
[
# What do I put here as an input??
]
)
def update_fields(href):
return get_field_options()

最佳答案

您可以使用plotly dash store组件来保存事件所需的一些数据。

dcc.Store(id='local', storage_type='local'),

Dash Store component

关于python - 在绘图破折号中更新回调之外的应用程序状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56285752/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com