# Create the RenderWindow, Renderer and both Actors ren1 = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren1) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) style = vtk.vtkInteractorStyleImage() iren.SetInteractorStyle(style) # VTK widgets consist of two parts: the widget part that handles event processing; # and the widget representation that defines how the widget appears in the scene # (i.e., matters pertaining to geometry). rep = vtk.vtkBiDimensionalRepresentation2D() widget = vtk.vtkBiDimensionalWidget() widget.SetInteractor(iren) widget.SetRepresentation(rep) widget.AddObserver("EndInteractionEvent", vtkBiDimensionalCallback) # Add the actors to the renderer, set the background and size ren1.AddActor(imageActor) ren1.SetBackground(0.1, 0.2, 0.4) renWin.SetSize(300, 300) # record events recorder = vtk.vtkInteractorEventRecorder() recorder.SetInteractor(iren)