Skip to content

Commit 9e5cba5

Browse files
committed
Deprecate is_pyqt5.
The function won't really make sense anymore after the release of PyQt6.
1 parent bb7f9b9 commit 9e5cba5

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,8 @@ NavigationToolbar2QT.parent
376376
This attribute is deprecated. In order to access the parent window, use
377377
``toolbar.canvas.parent()``. Once the deprecation period is elapsed, it will
378378
also be accessible as ``toolbar.parent()``.
379+
380+
``qt_compat.is_pyqt5``
381+
~~~~~~~~~~~~~~~~~~~~~~
382+
This function is deprecated in prevision of the future release of PyQt6. The
383+
Qt version can be checked using ``QtCore.qVersion()``.

examples/user_interfaces/embedding_in_qt_sgskip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import numpy as np
1616

17-
from matplotlib.backends.qt_compat import QtCore, QtWidgets, is_pyqt5
18-
if is_pyqt5():
17+
from matplotlib.backends.qt_compat import QtCore, QtWidgets
18+
if QtCore.qVersion().startswith("5"):
1919
from matplotlib.backends.backend_qt5agg import (
2020
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
2121
else:

lib/matplotlib/backends/backend_qt5.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _create_qApp():
106106
app = QtWidgets.QApplication.instance()
107107
if app is None:
108108
# check for DISPLAY env variable on X11 build of Qt
109-
if is_pyqt5():
109+
if QtCore.qVersion().startswith("5"):
110110
try:
111111
from PyQt5 import QtX11Extras
112112
is_x11_build = True
@@ -129,11 +129,10 @@ def _create_qApp():
129129
else:
130130
qApp = app
131131

132-
if is_pyqt5():
133-
try:
134-
qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
135-
except AttributeError:
136-
pass
132+
try:
133+
qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
134+
except AttributeError:
135+
pass
137136

138137

139138
def _allow_super_init(__init__):
@@ -337,7 +336,7 @@ def mouseReleaseEvent(self, event):
337336
FigureCanvasBase.button_release_event(self, x, y, button,
338337
guiEvent=event)
339338

340-
if is_pyqt5():
339+
if QtCore.qVersion().startswith("5"):
341340
def wheelEvent(self, event):
342341
x, y = self.mouseEventCoords(event)
343342
# from QWheelEvent::delta doc
@@ -674,7 +673,7 @@ def parent(self):
674673
return self._parent
675674

676675
def _icon(self, name, color=None):
677-
if is_pyqt5():
676+
if QtCore.qVersion().startswith("5"):
678677
name = name.replace('.png', '_large.png')
679678
pm = QtGui.QPixmap(os.path.join(self.basedir, name))
680679
if hasattr(pm, 'setDevicePixelRatio'):
@@ -905,7 +904,7 @@ def __init__(self, toolmanager, parent):
905904

906905
@property
907906
def _icon_extension(self):
908-
if is_pyqt5():
907+
if QtCore.qVersion().startswith("5"):
909908
return '_large.png'
910909
return '.png'
911910

lib/matplotlib/backends/qt_compat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def _isdeleted(obj): return not shiboken2.isValid(obj)
8383
raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
8484
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
8585

86+
@mpl.cbook.deprecated("3.3", alternative="QtCore.qVersion()")
8687
def is_pyqt5():
8788
return True
8889

@@ -138,6 +139,7 @@ def _isdeleted(obj): return not shiboken.isValid(obj)
138139
raise ValueError("Unexpected value for the 'backend.qt4' rcparam")
139140
QtWidgets = QtGui
140141

142+
@mpl.cbook.deprecated("3.3", alternative="QtCore.qVersion()")
141143
def is_pyqt5():
142144
return False
143145

@@ -174,4 +176,4 @@ def is_pyqt5():
174176
# These globals are only defined for backcompatibility purposes.
175177
ETS = dict(pyqt=(QT_API_PYQTv2, 4), pyside=(QT_API_PYSIDE, 4),
176178
pyqt5=(QT_API_PYQT5, 5), pyside2=(QT_API_PYSIDE2, 5))
177-
QT_RC_MAJOR_VERSION = 5 if is_pyqt5() else 4
179+
QT_RC_MAJOR_VERSION = 5 if QtCore.qVersion().startswith("5") else 4

0 commit comments

Comments
 (0)