I’m trying to add an observer to the camera (and call a function to set a slice plane normal to camera), the function itself works fine but the observer of the camera either states “TypeError: ‘NoneType’ object is not callable” or wrong arguments if i input anything else than vtk.vtkCommand.ModifiedEvent,
Here is the code i’ve tried :
#grab reformat widget and green slice
layoutManager = slicer.app.layoutManager()
reformatWidget = slicer.modules.reformat.widgetRepresentation()
targetslice = slicer.app.layoutManager().sliceWidget('Green')
sliceNode = targetslice.mrmlSliceNode()
reformatWidget.setEditedNode(sliceNode,"","")
reformatWidget.setNormalToCamera ()
# Grab camera and cameranode
view = layoutManager.threeDWidget(0).threeDView()
threeDViewNode = view.mrmlViewNode()
cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(threeDViewNode) ##grabs camera NODE
camera = cameraNode.GetCamera()
# function to call
def refresh():
reformatWidget.setNormalToCamera ()
#set observer <-------problematic part
cameraobserver = camera.AddObserver(vtk.vtkCommand.ModifiedEvent, refresh())
#also tried cameraobserver = camera.AddObserver("ModifiedEvent", refresh())
Any suggestions? thanks.