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

Mig*_*ell 3 python plotly plotly-dash

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

因此,我想运行一个稍后设置应用程序状态的函数,但设置状态的唯一方法似乎是使用@app.callback()装饰器,但问题是它们需要在触发之前监视属性或状态变量,但就我而言我没有观看 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()
Run Code Online (Sandbox Code Playgroud)

Dim*_*thu 5

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

dcc.Store(id='local', storage_type='local'),
Run Code Online (Sandbox Code Playgroud)

达世币商店组件