Custom Events for VTK

For some types of data can add a decorator to your callback that interprets the call data in python.

https://github.com/Kitware/VTK/blob/master/Wrapping/Python/vtk/util/misc.py#L6-L27

For most data types in Slicer, a vtkObject is actually returned as a wrapped version of whatever concrete subclass was passed in the payload, so it actually covers all slicer events that come from nodes or the scene or other classes.

You can also call InvokeEvent from python with a calldata (payload) argument.

In practice it’s often the case in Slicer that you don’t need calldata because knowing the caller is enough to get the information you want because what would otherwise be the payload data has already been set in the corresponding instance variable of the caller.

1 Like