Check out the following. If you place the ctx = dash.callback_context
at the start of your callback(s), you can use the info it provides to determine your answer (I believe, since I don’t know how your callbacks are invoked after first-page load). I have implemented a helper function to return True
or False
if the States
are not populated (which would be true on first load) or if inputs
are None
(which is typical on first page load). Hopefully this spawns an idea on how you can use this to satisfy your needs.
# Place this command at the start of each callback
ctx = dash.callback_context
# Show CTX values
print(u''' ctx = {}'''.format(json.dumps({
'states': ctx.states,
'triggered': ctx.triggered,
'inputs': ctx.inputs
}, indent=2)))
# Determine which dcc component invoked callback
clicked = ctx.triggered[0]['prop_id'].split('.')[0]
print(u'''user pressed = {}'''.format(clicked))