Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Dash Python应用程序按钮执行操作并刷新页面_Python_Python 3.x_Plotly Dash - Fatal编程技术网

使用Dash Python应用程序按钮执行操作并刷新页面

使用Dash Python应用程序按钮执行操作并刷新页面,python,python-3.x,plotly-dash,Python,Python 3.x,Plotly Dash,在Dash应用程序中需要一个回调函数来执行一些操作,然后刷新页面,使用HTML a标记只能实现页面重新加载 html.A(html.Button('Refresh Data'),href='/') 所需: app.layout = html.Div([html.Button(id="refresh")]) @app.callback(Output('???', '???'), [Input('refresh', 'n_clicks')]) def refresh(n):

在Dash应用程序中需要一个回调函数来执行一些操作,然后刷新页面,使用HTML a标记只能实现页面重新加载

html.A(html.Button('Refresh Data'),href='/')
所需:

app.layout = html.Div([html.Button(id="refresh")])

@app.callback(Output('???', '???'),
          [Input('refresh', 'n_clicks')])
def refresh(n):
## Perform some action ##
## call python function API ##
## Finally Refresh the Page ##
 ?
return ?

这应该满足您的需要:

html.A(html.Button('Refresh Page'),href='/'),

我想这是正确的方法:

将此添加到布局中:

dcc.Location(id='url', refresh=True),
回拨:

@app.callback(
    Output("url", "href"),
    Input("App-logo", "n_clicks"),
    prevent_initial_call=True,
)
def reload_data(_):
    return "/"