enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.28k stars 282 forks source link

Moving the cursor into a mayavi window causes a crash #1298

Open VoodooCode14 opened 2 months ago

VoodooCode14 commented 2 months ago

The following code:

import os

os.environ['ETS_TOOLKIT'] = 'qt6'

import mayavi.mlab
mayavi.mlab.test_plot3d()
mayavi.mlab.show()
quit()

leads to a crash, with the following error msg:

Traceback (most recent call last):
  File "/home/voodoocode/local_python/lib/python3.12/site-packages/tvtk/pyface/ui/qt4/QVTKRenderWindowInteractor.py", line 543, in mouseMoveEvent
    self.__saveX = int(ev.x()*pxr)
                       ^^^^
AttributeError: 'QMouseEvent' object has no attribute 'x'

Putting a breakpoint into line 59 of QVTKRenderWindowInteractor.py reveals that qt_api is (properly) set to pyqt6

This issue occurred after upgrading Python from 3.11 to 3.12.

This can be fixed as follows, changing lines 543, 544, 547, 547, 514, 514, 529, and 529 from

ev.x()

to

ev.position().x()

and

ev.y()

to

ev.position().y()

However, this will likely break earlier Qt versions (i.e. < 6) and needs corresponding handling.