Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Is there a way to distinguish user input from callback output?

$
0
0

@nfroehberg wrote:

Hi guys, does anyone know of a good way to differentiate weather a callback was triggered by the user input or by another callback? Specifically for components that don’t have the n_clicks property.
I’m using Dash to create a GUI for an electrochemical analyzer running on a backend script (I know that’s not what it’s intended to be used for but I love the possibilities it offers including easy integration of plotly graphs, so I’m hacking around a little). The issue is that I have some input components (like daq boolean switches) that occasionally get updated by processes running on the backend. So if I update the ‘on’ parameter of a boolean switch from the backend to reflect the state on the instrument, the callback of that switch gets triggered again.
I use an interval component with a callback to periodically check for updates from the backend and updating the ui elements accordingly.
An easy way to suppress the callback on those elements would be to update a second parameter (like a hidden div) on backend updates, so the callback of the input element could check that and only update if that indicator wasn’t set so the callback only fires when the user activates/deactivates the switch which wouldn’t set the indicator.
The problem with using a second indicator is that if I’m using it as a second input, that actually triggers the callback twice and if I’m using it as state, I can’t tell whether it’s been changed. That would be okay if the callback could itself reset the indicator but since it is already an output of the interval callback, so I can’t use it as an output of the switch callback. The restriction in Dash that an output cannot be set by more than one callback is really making things difficult for me. From other forum discussions, I understand that in many use cases multiple callbacks setting the same output can lead to problems, but here it would be really useful!
I hope it’s somewhat understandable what I’m trying to achieve and what the issue is. I’ll try and generate a minimal code example.
Any ideas would be much appreciated!

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images