add_event_handler#
- ImageWidget.add_event_handler(handler, event='current_index')[source]#
Register an event handler.
Currently the only event that ImageWidget supports is “current_index”. This event is emitted whenever the index of the ImageWidget changes.
- Parameters:
handler (callable) – callback function, must take a dict as the only argument. This dict will be the current_index
event (str, "current_index") – the only supported event is “current_index”
Example
def my_handler(index): print(index) # example prints: {"t": 100} if data has only time dimension # "z" index will be another key if present in the data, ex: {"t": 100, "z": 5} # create an image widget iw = ImageWidget(...) # add event handler iw.add_event_handler(my_handler)