Skip to content

Commit 83aa94d

Browse files
committed
Convert block=None to block=True
Fix doc
1 parent b117d39 commit 83aa94d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,11 @@ def draw_if_interactive(cls):
177177
cls.trigger_manager_draw(manager)
178178

179179
@classmethod
180-
def show(cls, block=None):
180+
def show(cls, block=True):
181181
"""Show all figures.
182182
183-
`show` blocks by calling `mainloop` if *block* is ``True``, or if it
184-
is ``None`` and we are neither in IPython's ``%pylab`` mode, nor in
185-
`interactive` mode.
183+
`show` blocks by calling `mainloop` if *block* is ``True`` and we are
184+
neither in IPython's ``%pylab`` mode, nor in `interactive` mode.
186185
"""
187186
managers = Gcf.get_all_fig_managers()
188187
if not managers:
@@ -198,7 +197,7 @@ def show(cls, block=None):
198197
return
199198
if cls.mainloop is None:
200199
return
201-
if block is None:
200+
if block:
202201
# Hack: Are we in IPython's pylab mode?
203202
from matplotlib import pyplot
204203
try:
@@ -210,8 +209,6 @@ def show(cls, block=None):
210209
block = not ipython_pylab and not is_interactive()
211210
# TODO: The above is a hack to get the WebAgg backend working with
212211
# ipython's `%pylab` mode until proper integration is implemented.
213-
if get_backend() == "WebAgg":
214-
block = True
215212
if block:
216213
cls.mainloop()
217214

@@ -244,7 +241,7 @@ class ShowBase(_Backend):
244241
Subclass must override mainloop() method.
245242
"""
246243

247-
def __call__(self, block=None):
244+
def __call__(self, block=True):
248245
return self.show(block=block)
249246

250247

@@ -2635,7 +2632,7 @@ def notify_axes_change(fig):
26352632
if self.toolmanager is None and self.toolbar is not None:
26362633
self.toolbar.update()
26372634

2638-
def show(self):
2635+
def show(self, block=True):
26392636
"""
26402637
For GUI backends, show the figure window and redraw.
26412638
For non-GUI backends, raise an exception to be caught

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def trigger_manager_draw(manager):
242242
manager.show()
243243

244244
@staticmethod
245-
def show(*args, **kwargs):
245+
def show(block=True):
246246
## TODO: something to do when keyword block==False ?
247247
from matplotlib._pylab_helpers import Gcf
248248

lib/matplotlib/backends/backend_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def draw_if_interactive():
172172
"""
173173

174174

175-
def show(block=None):
175+
def show(block=True):
176176
"""
177177
For image backends - is not required
178178
For GUI backends - show() is usually the last line of a pylab script and

lib/matplotlib/backends/backend_webagg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ def trigger_manager_draw(manager):
319319
manager.canvas.draw_idle()
320320

321321
@staticmethod
322-
def show():
322+
def show(block=True):
323+
if not block:
324+
warnings.warn('The webagg backend does not support "block=False"')
325+
block = True
323326
WebAggApplication.initialize()
324327

325328
url = "http://127.0.0.1:{port}{prefix}".format(

0 commit comments

Comments
 (0)