Skip to content

Commit 3f57e93

Browse files
committed
ENH: rename switch_backend -> select_gui_toolkit
switch_backend is the Matplotlib name for this function, select_gui_toolkit is clearer about what it is actually doing and why you would care!
1 parent d3f1162 commit 3f57e93

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

docs/source/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ Select the backend
7575
:toctree: _as_gen
7676
:nosignatures:
7777

78-
mpl_gui.switch_backend
78+
mpl_gui.select_gui_toolkit

mpl_gui/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ._figure import Figure # noqa: F401
2222

2323
from ._manage_interactive import ion, ioff, is_interactive # noqa: F401
24-
from ._manage_backend import switch_backend, current_backend_module as _cbm
24+
from ._manage_backend import select_gui_toolkit, current_backend_module as _cbm
2525
from ._promotion import promote_figure as promote_figure
2626
from ._creation import figure, subplots, subplot_mosaic # noqa: F401
2727

@@ -61,7 +61,7 @@ def show(figs, *, block=None, timeout=0):
6161
# TODO handle single figure
6262
if _cbm() is None:
6363
# set up the backend!
64-
switch_backend()
64+
select_gui_toolkit()
6565
managers = []
6666
for fig in figs:
6767
if fig.canvas.manager is not None:

mpl_gui/_manage_backend.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def current_backend_module():
1717
return _backend_mod
1818

1919

20-
def switch_backend(newbackend=None):
20+
def select_gui_toolkit(newbackend=None):
2121
"""
22-
Close all open figures and set the Matplotlib backend.
22+
Select the GUI toolkit to use.
2323
24-
The argument is case-insensitive. Switching to an interactive backend is
24+
The argument is case-insensitive. Switching between GUI toolkits is
2525
possible only if no event loop for another interactive backend has started.
2626
Switching to and from non-interactive backends is always possible.
2727
@@ -34,14 +34,13 @@ def switch_backend(newbackend=None):
3434
-------
3535
_Backend
3636
The backend selected.
37+
3738
"""
3839
global _backend_mod
3940

4041
# work-around the sentinel resolution in Matplotlib 😱
4142
if newbackend is None:
4243
newbackend = dict.__getitem__(rcParams, "backend")
43-
# make sure the init is pulled up so we can assign to it later
44-
import matplotlib.backends
4544

4645
if newbackend is rcsetup._auto_backend_sentinel:
4746
current_framework = cbook._get_running_interactive_framework()
@@ -67,14 +66,14 @@ def switch_backend(newbackend=None):
6766
# are of worse quality.
6867
for candidate in candidates:
6968
try:
70-
return switch_backend(candidate)
69+
return select_gui_toolkit(candidate)
7170
except ImportError:
7271
continue
7372

7473
else:
7574
# Switching to Agg should always succeed; if it doesn't, let the
7675
# exception propagate out.
77-
return switch_backend("agg")
76+
return select_gui_toolkit("agg")
7877

7978
if isinstance(newbackend, str):
8079
# Backends are implemented as modules, but "inherit" default method

mpl_gui/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ class TestingBackend(_Backend):
4444
Show = TestShow
4545

4646

47-
mpl_gui.switch_backend(TestingBackend)
47+
mpl_gui.select_gui_toolkit(TestingBackend)

0 commit comments

Comments
 (0)