[vtkusers] vtkInteractorStyleUser in Python
Charl P. Botha
c.p.botha at ewi.tudelft.nl
Thu Feb 26 07:03:59 EST 2004
On Thu, 2004-02-26 at 12:50, Roman Putanowicz wrote:
> I remember I have read that virtual methods do not propagate
> into Python. The question is then:
>
> How can one use vtkInteractorStyleUser in Python?
> The problem is that since VTK 4.2 the method SetKeyPressMethod
> is obsoleted, but as I understand the substitute for it, OnKeyPress,
> is a virtual one.
>
> All examples I was able to find uses SetKeyPressMethod.
>
> I would appreciate any hints.
In Python, things are invariably simpler than you think. Here's a
quickly slapped together example, but it should do what I think you want
to do:
# rwi is the wxVTKRenderWindowInteractor that you are using
def ce_cb(obj, evt_name):
if obj.GetKeyCode() == 'm':
print "you pressed m"
elif obj.GetKeyCode() == 'i':
print "you pressed i"
if obj.GetControlKey():
print "Control was pressed."
rwi.AddObserver('CharEvent', ce_cb)
--
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
More information about the vtkusers
mailing list