Custom vtkWidgetRepresentation in Python

Hello,

I am working with VTK 8.2 in Python 3.7 using the VTK distribution on Anaconda’s conda-forge channel.

I’m hoping to create a few custom widgets to interact with the data in the VTK scene. I haven’t attempted it yet, but I wanted to know if this is even possible in Python? Has anyone accomplished this or something similar?

The reason I’m skeptical it is possible is because in Python with VTK, overriding virtual methods is not possible and based on the documentation, I’ve noticed that vtkWidgetRepresentation and vtkAbstractWidget both have virtual methods within it.

In case you are wondering why I need custom widgets, here are the ones I want to create:

  • Custom line widget that has 2D widget handles. I am using vtkImageResliceMapper to only show one 2D slice of 3D data at a time, and I want to display a line widget with 2D handles (i.e. circles instead of spheres). Also, I want to have the ability to only move the point in one axis but allow translating it in any axis.
  • Custom square widget to draw a 2D box. Haven’t found anything similar in VTK yet

Thanks,
Addison