Skip to content

Commit ac05a41

Browse files
committed
API: make mg.show take positional variadic for input Figures
1 parent 65965ba commit ac05a41

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

docs/source/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ explicitly available ::
164164

165165
fig2 = Figure()
166166

167-
mg.show([fig1, fig2])
167+
mg.show(fig1, fig2)
168168

169169

170170
which will show both figures and block until they are closed. As part of the
@@ -186,7 +186,7 @@ Similar to `plt.ion<matplotlib.pyplot.ion>` and
186186

187187
mg.ioff()
188188
print(mg.is_interactive())
189-
mg.show([fig]) # will block!
189+
mg.show(fig) # will block!
190190

191191

192192
As with `plt.show<matplotlib.pyplot.show>`, you can explicitly control the
@@ -197,8 +197,8 @@ blocking behavior of `mg.show<mpl_gui.show>` via the *block* keyword argument ::
197197

198198
fig = Figure(label='control blocking')
199199

200-
mg.show([fig], block=False) # will never block
201-
mg.show([fig], block=True) # will always block
200+
mg.show(fig, block=False) # will never block
201+
mg.show(fig, block=True) # will always block
202202

203203

204204
The interactive state is shared Matplotlib and can also be controlled with

mpl_gui/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
_log = logging.getLogger(__name__)
4747

4848

49-
def show(figs, *, block=None, timeout=0):
49+
def show(*figs, block=None, timeout=0):
5050
"""
5151
Show the figures and maybe block.
5252
5353
Parameters
5454
----------
55-
figs : List[Figure]
55+
*figs : Figure
5656
The figures to show. If they do not currently have a GUI aware
5757
canvas + manager attached they will be promoted.
5858
@@ -247,7 +247,7 @@ def show_all(self, *, block=None, timeout=None):
247247
if timeout is None:
248248
timeout = self._timeout
249249
self._ensure_all_figures_promoted()
250-
show(self.figures, block=self._block, timeout=self._timeout)
250+
show(*self.figures, block=self._block, timeout=self._timeout)
251251

252252
# alias to easy pyplot compatibility
253253
show = show_all
@@ -368,7 +368,7 @@ def __enter__(self):
368368
def __exit__(self, exc_type, exc_value, traceback):
369369
if exc_value is not None and not self._forgive_failure:
370370
return
371-
show(self.figures, block=self._block, timeout=self._timeout)
371+
show(*self.figures, block=self._block, timeout=self._timeout)
372372

373373

374374
# from mpl_gui import * # is a langauge miss-feature

mpl_gui/tests/test_examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_no_pyplot():
1414
def test_promotion():
1515
fig = mg.Figure(label="test")
1616
assert fig.canvas.manager is None
17-
mg.show([fig], block=False)
17+
mg.show(*[fig], block=False)
1818
assert fig.canvas.manager is not None
1919

2020

@@ -32,7 +32,7 @@ def test_ion():
3232
ax = fig.subplots()
3333
(ln,) = ax.plot(range(5))
3434
ln.set_color("k")
35-
mg.show([fig], timeout=1)
35+
mg.show(*[fig], timeout=1)
3636
assert "start_event_loop" not in fig.canvas.call_info
3737

3838

@@ -43,7 +43,7 @@ def test_ioff():
4343

4444
def test_timeout():
4545
fig = mg.Figure()
46-
mg.show([fig], block=True, timeout=1)
46+
mg.show(*[fig], block=True, timeout=1)
4747
assert "start_event_loop" in fig.canvas.call_info
4848

4949

@@ -89,7 +89,7 @@ def test_close_all():
8989

9090
# test revive
9191
old_canvas = fig.canvas
92-
mg.show([fig])
92+
mg.show(fig)
9393
assert fig.canvas is not old_canvas
9494

9595

0 commit comments

Comments
 (0)