16
16
17
17
18
18
class 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
-
24
19
def __call__ (self , block = None ):
25
- from matplotlib import is_interactive
26
20
import matplotlib ._pylab_helpers as pylab_helpers
21
+ from matplotlib import is_interactive
27
22
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
32
26
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 )
39
33
40
34
41
35
show = Show ()
@@ -48,9 +42,7 @@ def draw_if_interactive():
48
42
if is_interactive ():
49
43
manager = pylab_helpers .Gcf .get_active ()
50
44
if manager is not None :
51
- if not manager .shown :
52
- manager .show ()
53
- manager .canvas .draw_idle ()
45
+ manager .show ()
54
46
55
47
56
48
def connection_info ():
@@ -96,16 +88,24 @@ class FigureManagerNbAgg(FigureManagerWebAgg):
96
88
ToolbarCls = NavigationIPy
97
89
98
90
def __init__ (self , canvas , num ):
99
- self .shown = False
91
+ self ._shown = False
100
92
FigureManagerWebAgg .__init__ (self , canvas , num )
101
93
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
+
102
99
def show (self ):
103
- if not self .shown :
100
+ if not self ._shown :
101
+ self .display_js ()
104
102
self ._create_comm ()
105
- self .shown = True
103
+ else :
104
+ self .canvas .draw_idle ()
105
+ self ._shown = True
106
106
107
107
def reshow (self ):
108
- self .shown = False
108
+ self ._shown = False
109
109
self .show ()
110
110
111
111
@property
0 commit comments