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

Skip to content

Commit ac2a145

Browse files
authored
Merge pull request #22051 from anntzer/rif
Make required_interactive_framework required on FigureCanvas.
2 parents 4af95cb + 2a964cc commit ac2a145

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``FigureCanvas`` without a ``required_interactive_framework`` attribute
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Support for such canvas classes is deprecated. Note that canvas classes which
4+
inherit from ``FigureCanvasBase`` always have such an attribute.

lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,9 +1650,13 @@ def _fix_ipython_backend2gui(cls):
16501650
# In case we ever move the patch to IPython and remove these APIs,
16511651
# don't break on our side.
16521652
return
1653-
rif = getattr(cls, "required_interactive_framework", None)
1654-
backend2gui_rif = {"qt": "qt", "gtk3": "gtk3", "gtk4": "gtk4",
1655-
"wx": "wx", "macosx": "osx"}.get(rif)
1653+
backend2gui_rif = {
1654+
"qt": "qt",
1655+
"gtk3": "gtk3",
1656+
"gtk4": "gtk4",
1657+
"wx": "wx",
1658+
"macosx": "osx",
1659+
}.get(cls.required_interactive_framework)
16561660
if backend2gui_rif:
16571661
if _is_non_interactive_terminal_ipython(ip):
16581662
ip.enable_gui(backend2gui_rif)

lib/matplotlib/pyplot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,13 @@ def findobj(o=None, match=None, include_self=True):
199199

200200

201201
def _get_required_interactive_framework(backend_mod):
202-
return getattr(
203-
backend_mod.FigureCanvas, "required_interactive_framework", None)
202+
if not hasattr(backend_mod.FigureCanvas, "required_interactive_framework"):
203+
_api.warn_deprecated(
204+
"3.6", name="Support for FigureCanvases without a "
205+
"required_interactive_framework attribute")
206+
return None
207+
# Inline this once the deprecation elapses.
208+
return backend_mod.FigureCanvas.required_interactive_framework
204209

205210

206211
def switch_backend(newbackend):

0 commit comments

Comments
 (0)