8000 Merge pull request #19894 from QuLogic/remove-qt4 · matplotlib/matplotlib@3bf56aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 3bf56aa

Browse files
authored
Merge pull request #19894 from QuLogic/remove-qt4
API: Remove deprecated Qt4 backends
2 parents 6cf9219 + e410271 commit 3bf56aa

File tree

21 files changed

+71
-259
lines changed

21 files changed

+71
-259
lines changed

doc/api/backend_qt_api.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ to building the docs.
66
.. redirect-from:: /api/backend_qt5agg_api
77
.. redirect-from:: /api/backend_qt5cairo_api
88

9-
:mod:`matplotlib.backends.backend_qt4agg`
10-
=========================================
11-
12-
.. module:: matplotlib.backends.backend_qt4agg
13-
14-
:mod:`matplotlib.backends.backend_qt4cairo`
15-
===========================================
16-
17-
.. module:: matplotlib.backends.backend_qt4cairo
18-
199
:mod:`matplotlib.backends.backend_qt5agg`
2010
=========================================
2111

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Qt4-based backends
2+
~~~~~~~~~~~~~~~~~~
3+
The qt4agg and qt4cairo backends have been removed. Qt4 has reached its
4+
end-of-life in 2015 and there are no releases of either PyQt4 or PySide for
5+
recent versions of Python. Please use one of the Qt5 or Qt6 backends.
6+
7+
``qt_compat.is_pyqt5``
8+
~~~~~~~~~~~~~~~~~~~~~~
9+
This function has been removed due to the release of PyQt6. The Qt version can
10+
be checked using ``QtCore.qVersion()``.
11+
12+
``matplotlib.backends.qt_editor.formsubplottool``
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
This module has been removed. Use
15+
``matplotlib.backends.backend_qt5.SubplotToolQt`` instead.

doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ accepted.
609609
Qt modifier keys
610610
~~~~~~~~~~~~~~~~
611611
The ``MODIFIER_KEYS``, ``SUPER``, ``ALT``, ``CTRL``, and ``SHIFT``
612-
global variables of the :mod:`matplotlib.backends.backend_qt4agg`,
613-
:mod:`matplotlib.backends.backend_qt4cairo`,
612+
global variables of the ``matplotlib.backends.backend_qt4agg``,
613+
``matplotlib.backends.backend_qt4cairo``,
614614
:mod:`matplotlib.backends.backend_qt5agg` and
615615
:mod:`matplotlib.backends.backend_qt5cairo` modules are deprecated.
616616

doc/devel/dependencies.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Matplotlib figures can be rendered to various user interfaces. See
4040
and the capabilities they provide.
4141

4242
* Tk_ (>= 8.3, != 8.6.0 or 8.6.1) [#]_: for the Tk-based backends.
43-
* PyQt4_ (>= 4.6) or PySide_ (>= 1.0.3) [#]_: for the Qt4-based backends.
4443
* PyQt5_ or PySide2_: for the Qt5-based backends.
4544
* PyGObject_: for the GTK3-based backends [#]_.
4645
* wxPython_ (>= 4) [#]_: for the wx-based backends.
@@ -49,8 +48,6 @@ and the capabilities they provide.
4948
* Tornado_: for the WebAgg backend.
5049

5150
.. _Tk: https://docs.python.org/3/library/tk.html
52-
.. _PyQt4: https://pypi.org/project/PyQt4
53-
.. _PySide: https://pypi.org/project/PySide
5451
.. _PyQt5: https://pypi.org/project/PyQt5
5552
.. _PySide2: https://pypi.org/project/PySide2
5653
.. _PyGObject: https://pygobject.readthedocs.io/en/latest/

examples/user_interfaces/embedding_in_qt_sgskip.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
import numpy as np
1616

1717
from matplotlib.backends.qt_compat import QtCore, QtWidgets
18-
if QtCore.qVersion() >= "5.":
19-
from matplotlib.backends.backend_qt5agg import (
20-
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
21-
else:
22-
from matplotlib.backends.backend_qt4agg import (
23-
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
18+
from matplotlib.backends.backend_qt5agg import (
19+
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
2420
from matplotlib.figure import Figure
2521

2622

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ def use(backend, *, force=True):
10661066
10671067
- interactive backends:
10681068
GTK3Agg, GTK3Cairo, MacOSX, nbAgg,
1069-
Qt4Agg, Qt4Cairo, Qt5Agg, Qt5Cairo,
1069+
Qt5Agg, Qt5Cairo,
10701070
TkAgg, TkCairo, WebAgg, WX, WXAgg, WXCairo
10711071
10721072
- non-interactive backends:

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def _safe_pyplot_import():
9999
if current_framework is None:
100100
raise # No, something else went wrong, likely with the install...
101101
backend_mapping = {'qt5': 'qt5agg',
102-
'qt4': 'qt4agg',
103102
'gtk3': 'gtk3agg',
104103
'wx': 'wxagg',
105104
'tk': 'tkagg',
@@ -1680,7 +1679,7 @@ class FigureCanvasBase:
16801679
A high-level figure instance.
16811680
"""
16821681

1683-
# Set to one of {"qt5", "qt4", "gtk3", "wx", "tk", "macosx"} if an
1682+
# Set to one of {"qt5", "gtk3", "wx", "tk", "macosx"} if an
16841683
# interactive framework is required, or None otherwise.
16851684
required_interactive_framework = None
16861685

@@ -1756,7 +1755,7 @@ def _fix_ipython_backend2gui(cls):
17561755
# don't break on our side.
17571756
return
17581757
rif = getattr(cls, "required_interactive_framework", None)
1759-
backend2gui_rif = {"qt5": "qt", "qt4": "qt", "gtk3": "gtk3",
1758+
backend2gui_rif = {"qt5": "qt", "gtk3": "gtk3",
17601759
"wx": "wx", "macosx": "osx"}.get(rif)
17611760
if backend2gui_rif:
17621761
if _is_non_interactive_terminal_ipython(ip):

lib/matplotlib/backends/backend_qt4.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

lib/matplotlib/backends/backend_qt4cairo.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/matplotlib/backends/backend_qt5.py

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ def _create_qApp():
124124

125125
def _allow_super_init(__init__):
126126
"""
127-
Decorator for ``__init__`` to allow ``super().__init__`` on PyQt4/PySide2.
127+
Decorator for ``__init__`` to allow ``super().__init__`` on PySide2.
128128
"""
129129

130130
if QT_API == "PyQt5":
131131

132132
return __init__
133133

134134
else:
135-
# To work around lack of cooperative inheritance in PyQt4, PySide,
136-
# and PySide2, when calling FigureCanvasQT.__init__, we temporarily
137-
# patch QWidget.__init__ by a cooperative version, that first calls
135+
# To work around lack of cooperative inheritance in PySide2, when
136+
# calling FigureCanvasQT.__init__, we temporarily patch
137+
# QWidget.__init__ by a cooperative version, that first calls
138138
# QWidget.__init__ with no additional arguments, and then finds the
139139
# next class in the MRO with an __init__ that does support cooperative
140-
# inheritance (i.e., not defined by the PyQt4, PySide, PySide2, sip
141-
# or Shiboken packages), and manually call its `__init__`, once again
142-
# passing the additional arguments.
140+
# inheritance (i.e., not defined by the PySide2, sip or Shiboken
141+
# packages), and manually call its `__init__`, once again passing the
142+
# additional arguments.
143143

144144
qwidget_init = QtWidgets.QWidget.__init__
145145

@@ -149,7 +149,7 @@ def cooperative_qwidget_init(self, *args, **kwargs):
149149
next_coop_init = next(
150150
cls for cls in mro[mro.index(QtWidgets.QWidget) + 1:]
151151
if cls.__module__.split(".")[0] not in [
152-
"PyQt4", "sip", "PySide", "PySide2", "Shiboken"])
152+
"sip", "PySide2", "Shiboken"])
153153
next_coop_init.__init__(self, *args, **kwargs)
154154

155155
@functools.wraps(__init__)
@@ -293,27 +293,16 @@ def mouseReleaseEvent(self, event):
293293
FigureCanvasBase.button_release_event(self, x, y, button,
294294
guiEvent=event)
295295

296-
if QtCore.qVersion() >= "5.":
297-
def wheelEvent(self, event):
298-
x, y = self.mouseEventCoords(event)
299-
# from QWheelEvent::delta doc
300-
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
301-
steps = event.angleDelta().y() / 120
302-
else:
303-
steps = event.pixelDelta().y()
304-
if steps:
305-
FigureCanvasBase.scroll_event(
306-
self, x, y, steps, guiEvent=event)
307-
else:
308-
def wheelEvent(self, event):
309-
x = event.x()
310-
# flipy so y=0 is bottom of canvas
311-
y = self.figure.bbox.height - event.y()
312-
# from QWheelEvent::delta doc
313-
steps = event.delta() / 120
314-
if event.orientation() == QtCore.Qt.Vertical:
315-
FigureCanvasBase.scroll_event(
316-
self, x, y, steps, guiEvent=event)
296+
def wheelEvent(self, event):
297+
x, y = self.mouseEventCoords(event)
298+
# from QWheelEvent::delta doc
299+
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
300+
steps = event.angleDelta().y() / 120
301+
else:
302+
steps = event.pixelDelta().y()
303+
if steps:
304+
FigureCanvasBase.scroll_event(
305+
self, x, y, steps, guiEvent=event)
317306

318307
def keyPressEvent(self, event):
319308
key = self._get_key(event)
@@ -650,8 +639,7 @@ def _icon(self, name):
650639
Construct a `.QIcon` from an image file *name*, including the extension
651640
and relative to Matplotlib's "images" data directory.
652641
"""
653-
if QtCore.qVersion() >= '5.':
654-
name = name.replace('.png', '_large.png')
642+
name = name.replace('.png', '_large.png')
655643
pm = QtGui.QPixmap(str(cbook._get_data_path('images', name)))
656644
_setDevicePixelRatio(pm, _devicePixelRatioF(self))
657645
if self.palette().color(self.backgroundRole()).value() < 128:

0 commit comments

Comments
 (0)
0