1010
1111from sys import getrefcount as grc
1212
13+
1314class FigureManagerEvent (object ):
1415def __init__ (self ,s ,fm ):
1516self .name = s
1617self .figure_manager = fm
1718
19+
1820class FigureManager (cbook .EventEmitter ):
1921def __init__ (self ,canvas ,num ):
2022cbook .EventEmitter .__init__ (self )
@@ -36,16 +38,18 @@ def __init__(self, canvas, num):
3638
3739self .toolbar = self ._get_toolbar (canvas )
3840if self .toolbar is not None :
39- h += self .window .add_element_to_window (self .toolbar ,False ,False ,0 )
41+ h += self .window .add_element_to_window (self .toolbar ,
42+ False ,False ,0 )
4043
41- self .window .set_default_size (w ,h )
44+ self .window .set_default_size (w ,h )
4245
4346if is_interactive ():
4447self .window .show ()
4548
4649def notify_axes_change (fig ):
4750'this will be called whenever the current axes is changed'
48- if self .toolbar is not None :self .toolbar .update ()
51+ if self .toolbar is not None :
52+ self .toolbar .update ()
4953self .canvas .figure .add_axobserver (notify_axes_change )
5054
5155self .canvas .grab_focus ()
@@ -68,7 +72,7 @@ def destroy(self, *args):
6872self .canvas .destroy ()
6973if self .toolbar :
7074self .toolbar .destroy ()
71-
75+
7276self .mainloop .__del__ ()
7377
7478def show (self ):
@@ -79,7 +83,7 @@ def full_screen_toggle(self):
7983self .window .set_fullscreen (self ._full_screen_flag )
8084
8185def resize (self ,w ,h ):
82- self .window .resize (w ,h )
86+ self .window .resize (w ,h )
8387
8488def get_window_title (self ):
8589"""
@@ -110,6 +114,7 @@ def _get_toolbar(self, canvas):
110114toolbar = None
111115return toolbar
112116
117+
113118def new_figure_manager (num ,* args ,** kwargs ):
114119"""
115120 Create a new figure manager instance
@@ -119,7 +124,7 @@ def new_figure_manager(num, *args, **kwargs):
119124FigureClass = kwargs .pop ('FigureClass' ,Figure )
120125thisFig = FigureClass (* args ,** kwargs )
121126manager = new_figure_manager_given_figure (num ,thisFig )
122- else :# TODO remove once Gcf removed from backends.
127+ else :# TODO remove once Gcf removed from backends.
123128manager = old_new_figure_manager (num ,* args ,** kwargs )
124129manager .mainloop = show
125130return manager