@@ -96,6 +96,15 @@ def show(self):
9696 else :
9797 self .canvas .draw_idle ()
9898 self ._shown = True
99+ # plt.figure adds an event which makes the figure in focus the active
100+ # one. Disable this behaviour, as it results in figures being put as
101+ # the active figure after they have been shown, even in non-interactive
102+ # mode.
103+ if hasattr (self , '_cidgcf' ):
104+ self .canvas .mpl_disconnect (self ._cidgcf )
105+ if not is_interactive ():
106+ from matplotlib ._pylab_helpers import Gcf
107+ Gcf .figs .pop (self .num , None )
99108
100109 def reshow (self ):
101110 """
@@ -232,27 +241,3 @@ def on_message(self, message):
232241class _BackendNbAgg (_Backend ):
233242 FigureCanvas = FigureCanvasNbAgg
234243 FigureManager = FigureManagerNbAgg
235-
236- @staticmethod
237- def show (block = None ):
238- ## TODO: something to do when keyword block==False ?
239- from matplotlib ._pylab_helpers import Gcf
240-
241- managers = Gcf .get_all_fig_managers ()
242- if not managers :
243- return
244-
245- interactive = is_interactive ()
246-
247- for manager in managers :
248- manager .show ()
249-
250- # plt.figure adds an event which makes the figure in focus the
251- # active one. Disable this behaviour, as it results in
252- # figures being put as the active figure after they have been
253- # shown, even in non-interactive mode.
254- if hasattr (manager , '_cidgcf' ):
255- manager .canvas .mpl_disconnect (manager ._cidgcf )
256-
257- if not interactive :
258- Gcf .figs .pop (manager .num , None )
0 commit comments