2

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".

1 Answer 1

3

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() 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.