diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2023-09-30 10:27:28 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2023-09-30 10:47:10 +0300 |
commit | 5a6373c9d09bbfb7094f9992a4531477bb97829e (patch) | |
tree | ebea8fd55fee858876743312cdf789a1f01487b5 /contrib/python/ipython/py3/IPython/core/pylabtools.py | |
parent | 15f3c7493474de25a6b23296878bb8f49470d2e6 (diff) | |
download | ydb-5a6373c9d09bbfb7094f9992a4531477bb97829e.tar.gz |
Update contrib/python/ipython/py3 to 8.15.0
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/pylabtools.py')
-rw-r--r-- | contrib/python/ipython/py3/IPython/core/pylabtools.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/pylabtools.py b/contrib/python/ipython/py3/IPython/core/pylabtools.py index deadf038ea..e5715a9497 100644 --- a/contrib/python/ipython/py3/IPython/core/pylabtools.py +++ b/contrib/python/ipython/py3/IPython/core/pylabtools.py @@ -23,7 +23,7 @@ backends = { "qt4": "Qt4Agg", "qt5": "Qt5Agg", "qt6": "QtAgg", - "qt": "Qt5Agg", + "qt": "QtAgg", "osx": "MacOSX", "nbagg": "nbAgg", "webagg": "WebAgg", @@ -53,8 +53,8 @@ backend2gui["CocoaAgg"] = "osx" # supports either Qt5 or Qt6 and the IPython qt event loop support Qt4, Qt5, # and Qt6. backend2gui["QtAgg"] = "qt" -backend2gui["Qt4Agg"] = "qt" -backend2gui["Qt5Agg"] = "qt" +backend2gui["Qt4Agg"] = "qt4" +backend2gui["Qt5Agg"] = "qt5" # And some backends that don't need GUI integration del backend2gui["nbAgg"] @@ -208,10 +208,12 @@ def mpl_runner(safe_execfile): #print '*** Matplotlib runner ***' # dbg # turn off rendering until end of script - is_interactive = matplotlib.rcParams['interactive'] - matplotlib.interactive(False) - safe_execfile(fname,*where,**kw) - matplotlib.interactive(is_interactive) + with matplotlib.rc_context({"interactive": False}): + safe_execfile(fname, *where, **kw) + + if matplotlib.is_interactive(): + plt.show() + # make rendering call now, if the user tried to do it if plt.draw_if_interactive.called: plt.draw() @@ -317,9 +319,15 @@ def find_gui_and_backend(gui=None, gui_select=None): import matplotlib + has_unified_qt_backend = getattr(matplotlib, "__version_info__", (0, 0)) >= (3, 5) + + backends_ = dict(backends) + if not has_unified_qt_backend: + backends_["qt"] = "qt5agg" + if gui and gui != 'auto': # select backend based on requested gui - backend = backends[gui] + backend = backends_[gui] if gui == 'agg': gui = None else: @@ -336,7 +344,7 @@ def find_gui_and_backend(gui=None, gui_select=None): # ones allowed. if gui_select and gui != gui_select: gui = gui_select - backend = backends[gui] + backend = backends_[gui] return gui, backend |