Need to have a callback function in Dash App for performing some action and then refreshing the page, only page reload could be achieved using HTML A tag.
html.A(html.Button('Refresh Data'),href='/')
Required:
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 ?
Dash is an open source framework for building data visualization interfaces. Released in 2017 as a Python library, it's grown to include implementations for R and Julia. Dash helps data scientists build analytical web applications without requiring advanced web development knowledge.
Whenever an input property changes, the function that the callback decorator wraps will get called automatically. Dash provides this callback function with the new value of the input property as its argument, and Dash updates the property of the output component with whatever was returned by the function.
Using dash. callback_context , you can determine which component/property pairs triggered a callback. Below is a summary of properties of dash. callback_context outlining the basics of when to use them. For more detail and examples see Determining Which Callback Input Changed.
Dash is a python framework created by plotly for creating interactive web applications. Dash is written on the top of Flask, Plotly. js and React. js. With Dash, you don't have to learn HTML, CSS and Javascript in order to create interactive dashboards, you only need python.
I guess this is the proper way to do it:
add this to your layout:
dcc.Location(id='url', refresh=True),
callback:
@app.callback(
Output("url", "href"),
Input("App-logo", "n_clicks"),
prevent_initial_call=True,
)
def reload_data(_):
return "/"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With