1616
1717
1818class Show (ShowBase ):
19- def display_js (self ):
20- # XXX How to do this just once? It has to deal with multiple
21- # browser instances using the same kernel.
22- display (Javascript (FigureManagerNbAgg .get_javascript ()))
23-
2419 def __call__ (self , block = None ):
25- from matplotlib import is_interactive
2620 import matplotlib ._pylab_helpers as pylab_helpers
21+ from matplotlib import is_interactive
2722
28- queue = pylab_helpers .Gcf ._activeQue
29- for manager in queue [:]:
30- if not manager .shown :
31- self .display_js ()
23+ managers = pylab_helpers .Gcf .get_all_fig_managers ()
24+ if not managers :
25+ return
3226
33- manager . show ()
34- # If we are not interactive, disable the figure from
35- # the active queue, but don't destroy it.
36- if not is_interactive ():
37- queue . remove ( manager )
38- manager . canvas . draw_idle ( )
27+ interactive = is_interactive ()
28+
29+ for manager in managers :
30+ manager . show ()
31+ if not interactive and manager in pylab_helpers . Gcf . _activeQue :
32+ pylab_helpers . Gcf . _activeQue . remove ( manager )
3933
4034
4135show = Show ()
@@ -48,9 +42,7 @@ def draw_if_interactive():
4842 if is_interactive ():
4943 manager = pylab_helpers .Gcf .get_active ()
5044 if manager is not None :
51- if not manager .shown :
52- manager .show ()
53- manager .canvas .draw_idle ()
45+ manager .show ()
5446
5547
5648def connection_info ():
@@ -96,16 +88,24 @@ class FigureManagerNbAgg(FigureManagerWebAgg):
9688 ToolbarCls = NavigationIPy
9789
9890 def __init__ (self , canvas , num ):
99- self .shown = False
91+ self ._shown = False
10092 FigureManagerWebAgg .__init__ (self , canvas , num )
10193
94+ def display_js (self ):
95+ # XXX How to do this just once? It has to deal with multiple
96+ # browser instances using the same kernel.
97+ display (Javascript (FigureManagerNbAgg .get_javascript ()))
98+
10299 def show (self ):
103- if not self .shown :
100+ if not self ._shown :
101+ self .display_js ()
104102 self ._create_comm ()
105- self .shown = True
103+ else :
104+ self .canvas .draw_idle ()
105+ self ._shown = True
106106
107107 def reshow (self ):
108- self .shown = False
108+ self ._shown = False
109109 self .show ()
110110
111111 @property
0 commit comments