Deprecate is_pyqt5. · matplotlib/matplotlib@38e2c4c · GitHub
Skip to content

Commit 38e2c4c

Browse files
committed
Deprecate is_pyqt5.
The function won't really make sense anymore after the release of PyQt6.
1 parent c92f717 commit 38e2c4c

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 5 additions & 0 deletions

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.QT_VERSION_STR >= "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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _create_qApp():
105105
app = QtWidgets.QApplication.instance()
106106
if app is None:
107107
# check for DISPLAY env variable on X11 build of Qt
108-
if is_pyqt5():
108+
if QtCore.QT_VERSION_STR >= "5.":
109109
try:
110110
importlib.import_module(
111111
# i.e. PyQt5.QtX11Extras or PySide2.QtX11Extras.
@@ -130,11 +130,10 @@ def _create_qApp():
130130
else:
131131
qApp = app
132132

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

139138

140139
def _allow_super_init(__init__):
@@ -332,7 +331,7 @@ def mouseReleaseEvent(self, event):
332331
FigureCanvasBase.button_release_event(self, x, y, button,
333332
guiEvent=event)
334333

335-
if is_pyqt5():
334+
if QtCore.QT_VERSION_STR >= "5.":
336335
def wheelEvent(self, event):
337336
x, y = self.mouseEventCoords(event)
338337
# from QWheelEvent::delta doc
@@ -699,7 +698,7 @@ def basedir(self):
699698
return str(cbook._get_data_path('images'))
700699

701700
def _icon(self, name, color=None):
702-
if is_pyqt5():
701+
if QtCore.QT_VERSION_STR >= '5.':
703702
name = name.replace('.png', '_large.png')
704703
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
705704
qt_compat._setDevicePixelRatio(pm, qt_compat._devicePixelRatio(self))
@@ -896,9 +895,7 @@ def __init__(self, toolmanager, parent):
896895

897896
@property
898897
def _icon_extension(self):
899-
if is_pyqt5():
900-
return '_large.png'
901-
return '.png'
898+
return '_large.png' if QtCore.QT_VERSION_STR >= '5.' else '.png'
902899

903900
def add_toolitem(
904901
self, name, group, position, image_file, description, toggle):

lib/matplotlib/backends/qt_compat.py

Lines changed: 4 additions & 2 deletions

0 commit comments

Comments
 (0)