enthought / mayavi

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

ENH: PySide6 support #1158

Closed rkern closed 2 years ago

rkern commented 2 years ago

And testing on Python 3.8.

I include a workaround for a lingering cycle that enthought/pyface#1143 cleans up until it is available to depend on. Both PySide2 and PySide6 present that bug, but not PyQt5 (and presumably other PyQtXs, but I did not check).

rkern commented 2 years ago

For some reason, the 3.8, pyside6, windows-latest run collects no tests from either mayavi or tvtk. All the others seem to run the whole test suite.

corranwebster commented 2 years ago

When running the application, I am getting some PySide6 errors coming from pyface in the Python shell:

Traceback (most recent call last):
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 243, in eventFilter
    return self._event_filter_console_keypress(event)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 366, in _event_filter_console_keypress
    return super()._event_filter_console_keypress(event)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1329, in _event_filter_console_keypress
    intercepted = not self._tab_pressed()
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 338, in _tab_pressed
    self._complete()
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 450, in _complete
    self._complete_with_items(cursor, completions)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1025, in _complete_with_items
    self._page(self._format_as_columns(items))
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1514, in _format_as_columns
    char_width = QtGui.QFontMetrics(self.font).width(" ")
AttributeError: 'PySide6.QtGui.QFontMetrics' object has no attribute 'width'

and

Traceback (most recent call last):
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 243, in eventFilter
    return self._event_filter_console_keypress(event)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/python_shell.py", line 366, in _event_filter_console_keypress
    return super()._event_filter_console_keypress(event)
  File "/Users/cwebster/.edm/envs/mayavi-38/lib/python3.8/site-packages/pyface/ui/qt4/console/console_widget.py", line 1352, in _event_filter_console_keypress
    cursor.movePosition(QtGui.QTextCursor.MoveOperation.Right, mode=anchormode)
AttributeError: PySide6.QtGui.QTextCursor.movePosition(): unsupported keyword 'mode'

These likely need to be fixed in Pyface.

Edit: I have opened issues for these in Pyface.

Edit: Hopefully both are fixed by https://github.com/enthought/pyface/pull/1148

corranwebster commented 2 years ago

Mouse wheel support needs updating in QVTKRenderWindowInteractor.py:

Traceback (most recent call last):
  File "/Users/cwebster/src/ets/mayavi/tvtk/pyface/ui/qt4/QVTKRenderWindowInteractor.py", line 559, in _emit_wheel_event
    ev = QWheelEvent(*self._saved_wheel_event_info)
TypeError: PySide6.QtGui.QWheelEvent.__init__(): not enough arguments
rkern commented 2 years ago

The wheel event stuff coalescence is actually only supposed to be activated on Qt4, but the test for that was written as PyQtImpl != 'PyQt5'. Changing that to look at is_qt4 instead makes sure that we use a codepath that doesn't need to synthesize QWheelEvents at all.

rkern commented 2 years ago

@prabhuramachandran I don't know how to change the required "Expected" workflows, so I will leave merging in your hands.

prabhuramachandran commented 2 years ago

@rkern -- I did not specifically add the expected workflows. I suspect @rahulporuri may know better. In any case I will try to find out what is up with this.

rahulporuri commented 2 years ago

@prabhuramachandran @rkern fixed up - the names of the required jobs changed (the 3.6 jobs now include pyqt5 and there are new 3.8 jobs with pyside6).

Expected workflows are set as part of branch protections - https://github.com/enthought/mayavi/settings/branches. Specifically, these required checks are for any PR against the master branch and we can enable/disable CI runs as required checks.

rkern commented 2 years ago

Thanks. @prabhuramachandran Since the branch protections have been updated and your release PR is being held up because of it, I am going to go ahead and merge. My apologies if it steps on your toes.