mayavi icon indicating copy to clipboard operation
mayavi copied to clipboard

Moving the cursor into a mayavi window causes a crash

Open VoodooCode14 opened this issue 1 year ago • 0 comments

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.

VoodooCode14 avatar May 01 '24 00:05 VoodooCode14