I am not sure if this is the expected behaviour or a bug, but if I do
curdoc().add_root(layout)
myfig.on_event(events.SelectionGeometry, my_python_func)
The callback is not registered and never called. However, if I switch the order of the lines and call on_event before doing add_root(layout), then the callback is registered and called correctly.
Following the MVC pattern, I was trying to create a GUI completely (including the add_root operation), with no callbacks associated until a Controller object is completely created, so that the controller methods are later registered as callbacks. I want the GUI class to be independent of everything else, that’s why I was creating all GUI elements with dummy datasources and no callbacks, and then update everything after the Controller has been created and initialized.
Thanks!