silx
silx copied to clipboard
Add support for PySide6/PyQt6
Related links:
- https://www.riverbankcomputing.com/static/Docs/PyQt6/pyqt5_differences.html
- https://doc.qt.io/qtforpython/porting_from2.html
- https://doc.qt.io/qt-6/portingguide.html
- https://www.learnpyqt.com/blog/pyqt6-vs-pyside6/
TODO list:
- [x] Remove code for PyQt4/PySide2 support
- [ ] Handle enums ~~Change enums to use fully qualified names, e.g.,
qt.Qt.ItemIsSelectable->qt.Qt.ItemFlags.ItemIsSelectable~~ - [ ] Testing/Handle specific cases
- [x] Handle change of naming in PyQt6 only:
exec_->exec(andprint_->print)
Status of enums changes accross Qt bindings by examples with ItemFlag's ItemIsSelectable
It comes in 3 flavors (!), with from <>.QtCore import Qt:
- Legacy (current way to access in silx):
Qt.ItemIsSelectable - New standard:
Qt.ItemFlag.ItemIsSelectable - pyqt6.0, mind the s in the enum name:
Qt.ItemFlags.ItemIsSelectable
Status of bindings:
-
PySide6: Legacy and New
-
PySide2: Legacy and New
-
PyQt6 >= 6.1: only New
-
PyQt 6 < 6.1: only pyqt6.0
-
PyQt5 >= 5.11: Legacy and New
-
PyQt5 < 5.11: only Legacy
To limit supported cases, we could:
- do NOT support
PyQt6==6.0which is an outlier - drop
PyQt5<5.11
and switch to the New syntax, otherwise we'll have to monkey-patch for PyQt6==6.0 and PyQt5<5.11 or make an explicit compatibility Qt enum module (but I would rather not).
Since we are already using legacy, I do not see much more work associated to adding compatibility with PyQt5 < 5.11 respect to the 100% move to the new syntax.
Not sure I understand:
- To support PyQt6 >=6.1 either we have to move to the new syntax or to make a monkey-patching to provide the legacy syntax.
- To support PyQt5 < 5.11 either we keep the current syntax or we make a monkey-patching to provide the new syntax.
So without monkey-patching, PyQt6 and PyQt5<5.11 support are mutually exclusive.
It's not just for enums in QtCore.Qt like ItemFlag, it's also the one in classes e.g., QtWidgets.QDockWidget.DockWidgetFeature.
Having to do monkey-patching, I prefer to do it to support older versions rather than newer ones.
BTW, having switches all over the code to support the different syntax is not an option to me.
Now, thinking of it, it's only PyQt6 that forces the new syntax, so maybe as long as PySide6 supports the legacy one, it's maybe best to stick with it. PyQt5>5.11, PyQt6.0 and PyQt6.1 are all using a different incompatible syntax.... while PySideX has not changed anything.
With PR #3479 tests pass in CI with PySide6 on macos, linux and windows.
As of today PyQt6 remains. Because of the enum name changes, I intend NOT to support PyQt6==6.0 and support PyQt6>=6.1.
PR #3542 fixes issues that could be found by manually testing examples/ and silx view with PySide6 on linux.
There is most probably still some PySide6 compatibility issues in some corners, but I would say that we can start to claim PySide6 support.
Finished with #3655 There may still be corner cases support missing (not covered by tests), but let's open dedicated issues for it.