How can I add a observer to a vtk Interactor Style Rubber Band Pick class?

I’m trying to add an Observer to a class that inherit from vtkInteractorStyleRubberBandPick.
My goal is to trigger a function when I finished to make a bouding box on the screen with the key ‘r’.
The issue is I don’t find a way to trigger my function when I release the left button.
I try to use the EndPickEvent but I never pass into the EndPickEventfunc
When the window opens, I press the ‘r’ key in order to select a square on the window, but when I finished to select the square (left mouse is released) I do not enter in the function self.EndPickEventfunc

import vtk

class MouseInteractorHighLightActor(vtk.vtkInteractorStyleRubberBandPick):

    def __init__(self, parent=None):
        self.AddObserver(vtk.vtkCommand.EndPickEvent, self.EndPickEventfunc)

    def EndPickEventfunc(self, obj, event):
        print('I was here!')
        clickPos = self.GetInteractor().GetEventPosition()

# A renderer and render window
renderer = vtk.vtkRenderer()
renderer.SetBackground(.3, .4, .5)

renwin = vtk.vtkRenderWindow()

# An interactor
interactor = vtk.vtkRenderWindowInteractor()

# add the custom style
style = MouseInteractorHighLightActor()

# Add spheres to play with
for i in range(10):
    source = vtk.vtkSphereSource()

    source.SetRadius(vtk.vtkMath.Random(.5, 1.0))
    source.SetCenter(vtk.vtkMath.Random(-5, 5), vtk.vtkMath.Random(-5, 5), vtk.vtkMath.Random(-5, 5))

    mapper = vtk.vtkPolyDataMapper()
    actor = vtk.vtkActor()

    actor.GetProperty().SetDiffuseColor(vtk.vtkMath.Random(.4, 1.0), vtk.vtkMath.Random(.4, 1.0), vtk.vtkMath.Random(.4, 1.0))


# Start

No one to help me?

You need to use a vtk.vtkCommand.EndPickEvent observer on an vtk.vtkRenderedAreaPicker and add that area picker to the vtkRenderWindowInteractor


I take advantage of this post to ask if it is possible to modify the shape of the box that is displayed when I pick an area with ‘r’? I would like it to be circle where the center is the position the mouse was at when I pressed the mouse and the radius the distance from that previous position and the current mouse position? Maybe I should open a new topic for that.

I’m not sure how to do that off the top of my head. I’d recommend making a new issue