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

Skip to content

Commit 208c3be

Browse files
committed
Fix Gcf.show_all()
1 parent 24e43b3 commit 208c3be

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

lib/matplotlib/_pylab_helpers.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,21 @@ def show_all(cls, block=None):
7676
for manager in managers:
7777
manager.show()
7878

79-
if block is not None:
80-
if block:
81-
manager._mainloop()
79+
if block is True:
80+
manager._mainloop()
81+
return
82+
elif block is False:
8283
return
8384

85+
# Hack: determine at runtime whether we are
86+
# inside ipython in pylab mode.
8487
from matplotlib import pyplot
8588
try:
8689
ipython_pylab = not pyplot.show._needmain
8790
# IPython versions >= 0.10 tack the _needmain
8891
# attribute onto pyplot.show, and always set
8992
# it to False, when in %pylab mode.
90-
ipython_pylab = ipython_pylab and get_backend() != 'WebAgg'
93+
ipython_pylab = ipython_pylab and manager.backend_name != 'webagg'
9194
# TODO: The above is a hack to get the WebAgg backend
9295
# working with ipython's `%pylab` mode until proper
9396
# integration is implemented.
@@ -97,9 +100,9 @@ def show_all(cls, block=None):
97100
# Leave the following as a separate step in case we
98101
# want to control this behavior with an rcParam.
99102
if ipython_pylab:
100-
block = False
103+
return
101104

102-
if not is_interactive() or get_backend() == 'WebAgg':
105+
if not is_interactive() or manager.backend_name == 'webagg':
103106
manager._mainloop()
104107

105108
@classmethod

lib/matplotlib/backend_managers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from matplotlib import is_interactive
2222
from matplotlib import rcParams
2323
from matplotlib.figure import Figure
24-
from matplotlib.backends import get_backend
24+
from matplotlib.backends import get_backend, backend as backend_name
2525

2626

2727
class FigureManagerEvent(object):
@@ -75,7 +75,7 @@ class FigureManager(cbook.EventEmitter):
7575
"""
7676
def __init__(self, figure, num, **kwargs):
7777
super(FigureManager, self).__init__(**kwargs)
78-
self._backend = get_backend()
78+
self._backend_name, self._backend = get_backend()
7979

8080
self.num = num
8181
self.figure = figure
@@ -193,6 +193,10 @@ def set_window_title(self, title):
193193
def backend(self):
194194
return self._backend
195195

196+
@property
197+
def backend_name(self):
198+
return self._backend_name
199+
196200
def _get_toolbar(self):
197201
try:
198202
# must be inited after the window, drawingArea and figure

lib/matplotlib/backends/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_backend(name=None):
3636
# the last argument is specifies whether to use absolute or relative
3737
# imports. 0 means only perform absolute imports.
3838
backend_name = get_backend_name(name)
39-
return __import__(backend_name, globals(), locals(),
39+
return backend_name, __import__(backend_name, globals(), locals(),
4040
[backend_name], 0)
4141

4242

@@ -68,7 +68,7 @@ def pylab_setup(name=None):
6868
6969
'''
7070
# Import the requested backend into a generic module object
71-
backend_mod = get_backend(name)
71+
backend_mod = get_backend(name)[1]
7272

7373
# Things we pull in from all backends
7474
new_figure_manager = getattr(backend_mod, 'new_figure_manager', None)

0 commit comments

Comments
 (0)