title: plotly dash, callback with 2 button inputs and a dropdown input
body: <p>How can I write a callback such that if button 1 is clicked, do A; if button 2 is clicked, do B; if a dropdown value is changed, do C?</p>
  
  <pre><code>import dash
  import dash_core_components as dcc
  import dash_html_components as html
  
  app = dash.Dash(__name__)
  app.layout = html.Div([
          html.H1('initial', id = 'h1'),
          html.Button('to upper', id = 'upper button', n_clicks_timestamp = '0'),
          html.Button('to lower', id = 'lower button', n_clicks_timestamp = '0'),
          dcc.Dropdown(options = [{'value':s, 'label': s} for s in ['good','bad']], value = 'good', id = 'set string')
      ])
  
  @app.callback(
           dash.dependencies.Output('h1', 'children'),
           [dash.dependencies.Input('upper button', 'n_clicks_timestamp'), 
            dash.dependencies.Input('lower button', 'n_clicks_timestamp'), 
            dash.dependencies.Input('set string', 'value')],
           [dash.dependencies.State('h1', 'children')]
      )
  def update(upper, lower, newstring, currentstring):
      upper, lower = int(upper), int(lower)
  
      # ???
      # if dropdown changed, return newstring
      # ???
  
      if upper &gt; lower:
          return currentstring.upper()
      if lower &gt; upper:
          return currentstring.lower()
  
      return newstring
  
  if __name__ == '__main__':
      app.run_server(debug=False)
  </code></pre>
  
  <p>Since the dropdown doesn't have a <code>timestamp</code> property, there is no way to decide if it is the latest change.</p>