Well, in my case, there are often non-empty values set to the input box. Like pre-defined standards, the last syntactical correct user input, messages like “Input this and that…” if the box is empty, and various other cases.
Would you consider the approach I posted above as a “non-hacky” and correct/appropriate way as well or could you suggest a better solution?
Based on your way, I also thought about defining a list of strings that would yield in a direct return, like
if new in predefined_strings: return
However this would also ignore user input in some of the cases mentioned at the beginning.
Additionally I found that constructs like
def foo(attr, old, new):
my_input_box.value = "some text"
do not end in endless callback loops but is only triggered one additional time.
foo gets executed twice if the user changes the value in the input box.
Often enough, I’m also ok with this, since the execution is very fast and it does not matter if it runs once or twice, but of course in general leaving it like this is not a good style