Skip to content

Commit 6535148

Browse files
OceanWolftacaswell
authored andcommitted
Cleanup
1 parent 85f0668 commit 6535148

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

lib/matplotlib/backend_managers.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ def __init__(self, figure, num):
8989
self.toolmanager = ToolManager(self.canvas.figure)
9090
self.toolbar = self._get_toolbar()
9191

92-
if self.toolmanager:
93-
tools.add_tools_to_manager(self.toolmanager)
94-
if self.toolbar:
95-
tools.add_tools_to_container(self.toolbar)
96-
self.statusbar = self._backend.Statusbar(self.toolmanager)
97-
h += self.window.add_element(self.statusbar, False, 'south')
92+
tools.add_tools_to_manager(self.toolmanager)
93+
if self.toolbar:
94+
tools.add_tools_to_container(self.toolbar)
95+
self.statusbar = self._backend.Statusbar(self.toolmanager)
96+
h += self.window.add_element(self.statusbar, False, 'south')
9897

9998
if self.toolbar is not None:
10099
h += self.window.add_element(self.toolbar, False, 'south')

lib/matplotlib/backends/__init__.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ def get_backend_name(name=None):
3636
return backend_name
3737

3838

39-
def get_backend():
40-
backend_name = get_backend_name()
39+
def get_backend(name=None):
40+
# Import the requested backend into a generic module object
41+
# the last argument is specifies whether to use absolute or relative
42+
# imports. 0 means only perform absolute imports.
43+
backend_name = get_backend_name(name)
4144
return __import__(backend_name, globals(), locals(),
4245
[backend_name], 0)
4346

@@ -70,18 +73,23 @@ def pylab_setup(name=None):
7073
7174
'''
7275
# Import the requested backend into a generic module object
73-
backend_name = get_backend_name(name)
74-
# the last argument is specifies whether to use absolute or relative
75-
# imports. 0 means only perform absolute imports.
76-
backend_mod = __import__(backend_name, globals(), locals(),
77-
[backend_name], 0)
76+
backend_mod = get_backend(name)
7877

7978
# Things we pull in from all backends
8079
new_figure_manager = backend_mod.new_figure_manager
8180

8281
# image backends like pdf, agg or svg do not need to do anything
8382
# for "show" or "draw_if_interactive", so if they are not defined
8483
# by the backend, just do nothing
84+
def do_nothing_show(*args, **kwargs):
85+
frame = inspect.currentframe()
86+
fname = frame.f_back.f_code.co_filename
87+
if fname in ('<stdin>', '<ipython console>'):
88+
warnings.warn("""
89+
Your currently selected backend, '%s' does not support show().
90+
Please select a GUI backend in your matplotlibrc file ('%s')
91+
or with matplotlib.use()""" %
92+
(backend, matplotlib.matplotlib_fname()))
8593

8694
def do_nothing(*args, **kwargs):
8795
pass
@@ -101,13 +109,3 @@ def do_nothing(*args, **kwargs):
101109
global backend
102110
backend = name
103111
return backend_mod, new_figure_manager, draw_if_interactive, show
104-
105-
def do_nothing_show(*args, **kwargs):
106-
frame = inspect.currentframe()
107-
fname = frame.f_back.f_code.co_filename
108-
if fname in ('<stdin>', '<ipython console>'):
109-
warnings.warn("""
110-
Your currently selected backend, '%s' does not support show().
111-
Please select a GUI backend in your matplotlibrc file ('%s')
112-
or with matplotlib.use()""" %
113-
(name, matplotlib.matplotlib_fname()))

0 commit comments

Comments
 (0)