Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make required_interactive_framework required on FigureCanvas. #22051

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 1 commit into from
Dec 25, 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
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/22051-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``FigureCanvas`` without a ``required_interactive_framework`` attribute
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for such canvas classes is deprecated. Note that canvas classes which
inherit from ``FigureCanvasBase`` always have such an attribute.
10 changes: 7 additions & 3 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,13 @@ def _fix_ipython_backend2gui(cls):
# In case we ever move the patch to IPython and remove these APIs,
# don't break on our side.
return
rif = getattr(cls, "required_interactive_framework", None)
backend2gui_rif = {"qt": "qt", "gtk3": "gtk3", "gtk4": "gtk4",
"wx": "wx", "macosx": "osx"}.get(rif)
backend2gui_rif = {
"qt": "qt",
"gtk3": "gtk3",
"gtk4": "gtk4",
"wx": "wx",
"macosx": "osx",
}.get(cls.required_interactive_framework)
if backend2gui_rif:
if _is_non_interactive_terminal_ipython(ip):
ip.enable_gui(backend2gui_rif)
Expand Down
9 changes: 7 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,13 @@ def findobj(o=None, match=None, include_self=True):


def _get_required_interactive_framework(backend_mod):
return getattr(
backend_mod.FigureCanvas, "required_interactive_framework", None)
if not hasattr(backend_mod.FigureCanvas, "required_interactive_framework"):
_api.warn_deprecated(
"3.6", name="Support for FigureCanvases without a "
"required_interactive_framework attribute")
return None
# Inline this once the deprecation elapses.
return backend_mod.FigureCanvas.required_interactive_framework


def switch_backend(newbackend):
Expand Down