Skip to content

Commit 554670a

Browse files
committed
Fix compatibility with PySide6 6.4.0
1 parent d8a7253 commit 554670a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/matplotlib/backends/qt_compat.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969

7070

7171
def _setup_pyqt5plus():
72-
global QtCore, QtGui, QtWidgets, __version__, _isdeleted, _getSaveFileName
72+
global QtCore, QtGui, QtWidgets, __version__
73+
global _getSaveFileName, _isdeleted, _to_int
7374

7475
if QT_API == QT_API_PYQT6:
7576
from PyQt6 import QtCore, QtGui, QtWidgets, sip
@@ -78,10 +79,15 @@ def _setup_pyqt5plus():
7879
QtCore.Slot = QtCore.pyqtSlot
7980
QtCore.Property = QtCore.pyqtProperty
8081
_isdeleted = sip.isdeleted
82+
_to_int = operator.attrgetter('value')
8183
elif QT_API == QT_API_PYSIDE6:
8284
from PySide6 import QtCore, QtGui, QtWidgets, __version__
8385
import shiboken6
8486
def _isdeleted(obj): return not shiboken6.isValid(obj)
87+
if __version__ >= '6.4':
88+
_to_int = operator.attrgetter('value')
89+
else:
90+
_to_int = int
8591
elif QT_API == QT_API_PYQT5:
8692
from PyQt5 import QtCore, QtGui, QtWidgets
8793
import sip
@@ -90,6 +96,7 @@ def _isdeleted(obj): return not shiboken6.isValid(obj)
9096
QtCore.Slot = QtCore.pyqtSlot
9197
QtCore.Property = QtCore.pyqtProperty
9298
_isdeleted = sip.isdeleted
99+
_to_int = int
93100
elif QT_API == QT_API_PYSIDE2:
94101
from PySide2 import QtCore, QtGui, QtWidgets, __version__
95102
try:
@@ -98,6 +105,7 @@ def _isdeleted(obj): return not shiboken6.isValid(obj)
98105
import shiboken2
99106
def _isdeleted(obj):
100107
return not shiboken2.isValid(obj)
108+
_to_int = int
101109
else:
102110
raise AssertionError(f"Unexpected QT_API: {QT_API}")
103111
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
@@ -144,9 +152,6 @@ def _isdeleted(obj):
144152
# PyQt6 enum compat helpers.
145153

146154

147-
_to_int = operator.attrgetter("value") if QT_API == "PyQt6" else int
148-
149-
150155
@functools.lru_cache(None)
151156
def _enum(name):
152157
# foo.bar.Enum.Entry (PyQt6) <=> foo.bar.Entry (non-PyQt6).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy