def setup_observers(self, vtk_obj, event, method): """Setup the observer for the VTK object's event. Parameters ---------- vtk_obj -- The VTK object for which the `event` is observed. event -- The VTK event to watch. method -- The method to be called back when `event` is fired on the VTK object. """ # Setup the observer so the traits are updated even if the # wrapped VTK object changes. if hasattr(vtk_obj, 'AddObserver'): # Some classes like vtkInformation* derive from # tvtk.ObjectBase which don't support Add/RemoveObserver. messenger.connect(vtk_obj, event, method) ob_id = vtk_obj.AddObserver(event, messenger.send) key = vtk_obj.__this__ od = self._observer_data if key in od: od[key].append((vtk_obj, ob_id)) else: od[key] = [(vtk_obj, ob_id)]
def __init__(self): """ Initialize the editor component of script editor """ self.imports = [] messenger.connect(None, "record_code", self.onRecordCode) self.code = [] # Just a debug message, but we access scripting so pylint doesn't claim it's unused if scripting.record: Logging.info("Recording is enabled", kw="scripting")