I have been playing with ipywidget for only a week so please be gentle
I am currently trying to build a custom widget for audio annotation.
On Javascript side, I have something like
render() {
...
this.model.on('change:regions', this.regions_changed, this);
...
}
regions_changed() {
console.log("regions_changed");
}
sync_regions(regions) {
this.model.set('regions', regions);
this.touch();
// this.model.save_changes();
}
On Python side, I have something like
@widgets.register
class AudioWidget(widgets.DOMWidget):
...
regions = List().tag(sync=True)
As expected, calling sync_regions(regions)
on Javascript side will result in regions
attribute be updated on Python side.
However, the change:regions
event is also triggered on Javascript side. Is this expected?
My expectations were that it should only be triggered when regions
is updated manually on Python side (and not through the built-in ipywidget Javascript → Python sync).
If it is the expected behavior, how would one go to prevent the change:regions
event from being triggered?
Thanks for your help!
PS: same behavior happens using this.model.save_changes()
instead of this.touch()
but I probably don’t know what I am doing here