I’ve published the new versions now, here’s a quick example:
# Determine which input changed, or which button was clicked, using
# the latest functionality in dash-html-components (https://github.com/plotly/dash-html-components/pull/45)
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div([
html.Button('Button 1', id='btn-1', n_clicks_timestamp='0'),
html.Button('Button 2', id='btn-2', n_clicks_timestamp='0'),
html.Button('Button 3', id='btn-3', n_clicks_timestamp='0'),
def display(btn1, btn2, btn3):
if int(btn1) > int(btn2) and int(btn1) > int(btn3):
msg = 'Button 1 was most recently clicked'
elif int(btn2) > int(btn1) and int(btn2) > int(btn3):
msg = 'Button 2 was most recently clicked'
elif int(btn3) > int(btn1) and int(btn3) > int(btn2):
msg = 'Button 3 was most recently clicked'
msg = 'None of the buttons have been clicked yet'
if __name__ == '__main__':
To use, upgrade to the latest
n_clicks_timestamp property is available for all elements in
dash-html-components. We still need a solution that’s generally available for _all_components and all properties, but this is a start.
Thanks for the feedback everyone!