[vtkusers] GetKeySym and GetKeyCode for QVTKRenderWindowInteractor
Greg Schussman
greg.schussman at gmail.com
Thu Aug 28 17:14:38 EDT 2014
Hi.
I've got a working python vtk demo that uses a vtkRenderWindowInteractor,
with the style set to vtkInteractorStyleTrackballCamera. I run into a
problem when I try to embed this in Qt.
I use interactor.AddObserver('KeyPressEvent', key_handler) to see key
presses and act on them.
In my key_handler function, I query the interactor (passed in as an
argument to key_handler) about which key was pressed.
In my working example:
when I press 'b',
interactor.GetKeyCode() gives 'b', and
interactor.GetKeySym() give 'b'.
when I press esc,
interactor.GetKeyCode() gives an unprintable character, and
interactor.GetKeySym() gives 'Escape'.
In my non-working Qt example, I use QVTKRenderWindowInteractor(frame)
instead (copied from the VTK/Examples/Python/Widgets/EmbedPyQt example).
now, when I press 'b',
interactor.GetKeyCode() gives 'b', and
interactor.GetKeySym() gives None.
when I press esc,
interactor.GetKeyCode() gives an unprintable character, and
interactor.GetKeySym() gives None.
So, originally, I used GetKeySym(), but when switching to the
QVTKRenderWindowInteractor, that stopped working (always returning None).
I'm concerned about possible inconsistencies from one linux machine to
another when using GetKeyCode, so I'm reluctant to use it.
What should I do here? Is there any reason why the
QTVTKRenderWindowInteractor would be giving None for the KeySym?
For what it's worth, my demo code runs both with regular vtk and embedded
in pyqt, and the mouse interaction is fine, and the '3' option does toggle
stereo in both cases. But for some reason my observer can see the key with
GetKeySym in regular vtk mode, but not in embedded pyqt mode.
Thanks in advance for any help or suggestions.
Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140828/5e837077/attachment.html>
More information about the vtkusers
mailing list