11
22import matplotlib
3- from matplotlib .rcsetup import interactive_bk
4- from matplotlib .rcsetup import non_interactive_bk
5- from matplotlib .rcsetup import all_backends
6- from matplotlib .rcsetup import validate_backend
3+
74
85__all__ = ['backend' ,'show' ,'draw_if_interactive' ,
96 'new_figure_manager' , 'backend_version' ]
@@ -14,27 +11,23 @@ def pylab_setup():
1411 'return new_figure_manager, draw_if_interactive and show for pylab'
1512 # Import the requested backend into a generic module object
1613
17- backend_name = 'backend_' + backend
18- backend_name = backend_name .lower () # until we banish mixed case
19- backend_mod = __import__ ('matplotlib.backends.' + backend_name ,
14+ if backend .startswith ('module://' ):
15+ backend_name = backend [9 :]
16+ else :
17+ backend_name = 'backend_' + backend
18+ backend_name = backend_name .lower () # until we banish mixed case
19+ backend_name = 'matplotlib.backends.%s' % backend_name .lower ()
20+ backend_mod = __import__ (backend_name ,
2021 globals (),locals (),[backend_name ])
2122
2223 # Things we pull in from all backends
2324 new_figure_manager = backend_mod .new_figure_manager
2425
25- if hasattr (backend_mod ,'backend_version' ):
26- backend_version = getattr (backend_mod ,'backend_version' )
27- else : backend_version = 'unknown'
28-
29-
3026
31- # Now define the public API according to the kind of backend in use
32- if backend in interactive_bk :
33- show = backend_mod .show
34- draw_if_interactive = backend_mod .draw_if_interactive
35- else : # non-interactive backends
36- def draw_if_interactive (): pass
37- def show (): pass
27+ def do_nothing (* args , ** kwargs ): pass
28+ backend_version = getattr (backend_mod ,'backend_version' , 'unknown' )
29+ show = getattr (backend_mod , 'show' , do_nothing )
30+ draw_if_interactive = getattr (backend_mod , 'draw_if_interactive' , do_nothing )
3831
3932 # Additional imports which only happen for certain backends. This section
4033 # should probably disappear once all backends are uniform.
0 commit comments