8000 Remove deprecated Qt4 backends by QuLogic · Pull Request #19894 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove deprecated Qt4 backends #19894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions doc/api/backend_qt_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ to building the docs.
.. redirect-from:: /api/backend_qt5agg_api
.. redirect-from:: /api/backend_qt5cairo_api

:mod:`matplotlib.backends.backend_qt4agg`
=========================================

.. module:: matplotlib.backends.backend_qt4agg

:mod:`matplotlib.backends.backend_qt4cairo`
===========================================

.. module:: matplotlib.backends.backend_qt4cairo

:mod:`matplotlib.backends.backend_qt5agg`
=========================================

Expand Down
15 changes: 15 additions & 0 deletions doc/api/next_api_changes/removals/19894-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Qt4-based backends
~~~~~~~~~~~~~~~~~~
The qt4agg and qt4cairo backends have been removed. Qt4 has reached its
end-of-life in 2015 and there are no releases of either PyQt4 or PySide for
recent versions of Python. Please use one of the Qt5 or Qt6 backends.

``qt_compat.is_pyqt5``
~~~~~~~~~~~~~~~~~~~~~~
This function has been removed due to the release of PyQt6. The Qt version can
be checked using ``QtCore.qVersion()``.

``matplotlib.backends.qt_editor.formsubplottool``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This module has been removed. Use
``matplotlib.backends.backend_qt5.SubplotToolQt`` instead.
4 changes: 2 additions & 2 deletions doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ accepted.
Qt modifier keys
~~~~~~~~~~~~~~~~
The ``MODIFIER_KEYS``, ``SUPER``, ``ALT``, ``CTRL``, and ``SHIFT``
global variables of the :mod:`matplotlib.backends.backend_qt4agg`,
:mod:`matplotlib.backends.backend_qt4cairo`,
global variables of the ``matplotlib.backends.backend_qt4agg``,
``matplotlib.backends.backend_qt4cairo``,
:mod:`matplotlib.backends.backend_qt5agg` and
:mod:`matplotlib.backends.backend_qt5cairo` modules are deprecated.

Expand Down
3 changes: 0 additions & 3 deletions doc/devel/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Matplotlib figures can be rendered to various user interfaces. See
and the capabilities they provide.

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

.. _Tk: https://docs.python.org/3/library/tk.html
.. _PyQt4: https://pypi.org/project/PyQt4
.. _PySide: https://pypi.org/project/PySide
.. _PyQt5: https://pypi.org/project/PyQt5
.. _PySide2: https://pypi.org/project/PySide2
.. _PyGObject: https://pygobject.readthedocs.io/en/latest/
Expand Down
8 changes: 2 additions & 6 deletions examples/user_interfaces/embedding_in_qt_sgskip.py
6D40
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
import numpy as np

from matplotlib.backends.qt_compat import QtCore, QtWidgets
if QtCore.qVersion() >= "5.":
from matplotlib.backends.backend_qt5agg import (
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
else:
from matplotlib.backends.backend_qt4agg import (
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
from matplotlib.backends.backend_qt5agg import (
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
from matplotlib.figure import Figure


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ def use(backend, *, force=True):

- interactive backends:
GTK3Agg, GTK3Cairo, MacOSX, nbAgg,
Qt4Agg, Qt4Cairo, Qt5Agg, Qt5Cairo,
Qt5Agg, Qt5Cairo,
TkAgg, TkCairo, WebAgg, WX, WXAgg, WXCairo

- non-interactive backends:
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def _safe_pyplot_import():
if current_framework is None:
raise # No, something else went wrong, likely with the install...
backend_mapping = {'qt5': 'qt5agg',
'qt4': 'qt4agg',
'gtk3': 'gtk3agg',
'wx': 'wxagg',
'tk': 'tkagg',
Expand Down Expand Up @@ -1680,7 +1679,7 @@ class FigureCanvasBase:
A high-level figure instance.
"""

# Set to one of {"qt5", "qt4", "gtk3", "wx", "tk", "macosx"} if an
# Set to one of {"qt5", "gtk3", "wx", "tk", "macosx"} if an
# interactive framework is required, or None otherwise.
required_interactive_framework = None

Expand Down Expand Up @@ -1756,7 +1755,7 @@ def _fix_ipython_backend2gui(cls):
# don't break on our side.
return
rif = getattr(cls, "required_interactive_framework", None)
backend2gui_rif = {"qt5": "qt", "qt4": "qt", "gtk3": "gtk3",
backend2gui_rif = {"qt5": "qt", "gtk3": "gtk3",
"wx": "wx", "macosx": "osx"}.get(rif)
if backend2gui_rif:
if _is_non_interactive_terminal_ipython(ip):
Expand Down
15 changes: 0 additions & 15 deletions lib/matplotlib/backends/backend_qt4.py

This file was deleted.

16 changes: 0 additions & 16 deletions lib/matplotlib/backends/backend_qt4agg.py

This file was deleted.

11 changes: 0 additions & 11 deletions lib/matplotlib/backends/backend_qt4cairo.py

This file was deleted.

50 changes: 19 additions & 31 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@ def _create_qApp():

def _allow_super_init(__init__):
"""
Decorator for ``__init__`` to allow ``super().__init__`` on PyQt4/PySide2.
Decorator for ``__init__`` to allow ``super().__init__`` on PySide2.
"""

if QT_API == "PyQt5":

return __init__

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

qwidget_init = QtWidgets.QWidget.__init__

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

@functools.wraps(__init__)
Expand Down Expand Up @@ -293,27 +293,16 @@ def mouseReleaseEvent(self, event):
FigureCanvasBase.button_release_event(self, x, y, button,
guiEvent=event)

if QtCore.qVersion() >= "5.":
def wheelEvent(self, event):
x, y = self.mouseEventCoords(event)
# from QWheelEvent::delta doc
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
steps = event.angleDelta().y() / 120
else:
steps = event.pixelDelta().y()
if steps:
FigureCanvasBase.scroll_event(
self, x, y, steps, guiEvent=event)
else:
def wheelEvent(self, event):
x = event.x()
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y()
# from QWheelEvent::delta doc
steps = event.delta() / 120
if event.orientation() == QtCore.Qt.Vertical:
FigureCanvasBase.scroll_event(
self, x, y, steps, guiEvent=event)
def wheelEvent(self, event):
x, y = self.mouseEventCoords(event)
# from QWheelEvent::delta doc
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
steps = event.angleDelta().y() / 120
else:
steps = event.pixelDelta().y()
if steps:
FigureCanvasBase.scroll_event(
self, x, y, steps, guiEvent=event)

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