1

I want to disable some VTK hotkeys, in the Python version. While there exist answers here for C++ (and maybe js), it does not seem to work with the Python version.

I tried overloading OnKeyPress on my InterfactionStyle or my QVTKRenderWindowInteractor but it does not work. For example I would like to disable the wireframe/surface view switch that are on keys "w" and "s".

Abdul Hoque Nuri
  • 1,105
  • 1
  • 9
  • 18
Naomi
  • 45
  • 6

1 Answers1

2

It is defined in vtkInteractorStyle::OnChar. So try overload this method, with something like that:

class MyInteractorStyle(vtk.vtkInteractorStyleTrackballCamera):                                                                                                                                                                                                                             
  def __init__(self, parent = None):                                                                                                                                                                                                                                                        
    self.AddObserver('CharEvent', self.OnChar)                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                            
  def OnChar(self, obj, event):                                                                                                                                                                                                                                                             
      if obj.GetInteractor().GetKeyCode() == "w":                                                                                                                                                                                                                                           
          return                                                                                                                                                                                                                                                                            
      super(MyInteractorStyle, obj).OnChar() 
Nico Vuaille
  • 2,310
  • 1
  • 6
  • 14