<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi.<br><br></div>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.<br>
<br></div>I use interactor.AddObserver('KeyPressEvent', key_handler) to see key presses and act on them.<br><br></div>In my key_handler function, I query the interactor (passed in as an argument to key_handler) about which key was pressed.<br>
<br></div>In my working example:<br><br></div><div style="margin-left:40px">when I press 'b', <br></div><div style="margin-left:40px">interactor.GetKeyCode() gives 'b', and<br>interactor.GetKeySym() give 'b'.<br>
<br>when I press esc,<br>interactor.GetKeyCode() gives an unprintable character, and<br>interactor.GetKeySym() gives 'Escape'.<br></div></div></div></div><br></div>In my non-working Qt example, I use QVTKRenderWindowInteractor(frame) instead (copied from the VTK/Examples/Python/Widgets/EmbedPyQt example).<br>
</div><div><br></div><div style="margin-left:40px">now, when I press 'b',<br>interactor.GetKeyCode() gives 'b', and<br>interactor.GetKeySym() gives None.<br><br></div></div></div></div><div style="margin-left:40px">
when I press esc,<br>interactor.GetKeyCode() gives an unprintable character, and<br></div><div><div style="margin-left:40px">interactor.GetKeySym() gives None.<br><br></div>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.<br>
<br></div><div>What should I do here?  Is there any reason why the QTVTKRenderWindowInteractor would be giving None for the KeySym?<br><br></div><div>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.<br>
<br></div><div>Thanks in advance for any help or suggestions.<br><br>Greg<br><br></div><div><br><br></div><div><div><div><div><div><br><br></div></div></div></div></div></div>