@@ -35,106 +35,106 @@ class Gcf(object):
35
35
_activeQue = []
36
36
figs = {}
37
37
38
- @staticmethod
39
- def get_fig_manager (num ):
38
+ @classmethod
39
+ def get_fig_manager (cls , num ):
40
40
"""
41
41
If figure manager *num* exists, make it the active
42
42
figure and return the manager; otherwise return *None*.
43
43
"""
44
- manager = Gcf .figs .get (num , None )
44
+ manager = cls .figs .get (num , None )
45
45
if manager is not None :
46
- Gcf .set_active (manager )
46
+ cls .set_active (manager )
47
47
return manager
48
48
49
- @staticmethod
50
- def destroy (num ):
49
+ @classmethod
50
+ def destroy (cls , num ):
51
51
"""
52
52
Try to remove all traces of figure *num*.
53
53
54
54
In the interactive backends, this is bound to the
55
55
window "destroy" and "delete" events.
56
56
"""
57
- if not Gcf .has_fignum (num ):
57
+ if not cls .has_fignum (num ):
58
58
return
59
- manager = Gcf .figs [num ]
59
+ manager = cls .figs [num ]
60
60
manager .canvas .mpl_disconnect (manager ._cidgcf )
61
61
62
62
# There must be a good reason for the following careful
63
63
# rebuilding of the activeQue; what is it?
64
- oldQue = Gcf ._activeQue [:]
65
- Gcf ._activeQue = []
64
+ oldQue = cls ._activeQue [:]
65
+ cls ._activeQue = []
66
66
for f in oldQue :
67
67
if f != manager :
68
- Gcf ._activeQue .append (f )
68
+ cls ._activeQue .append (f )
69
69
70
- del Gcf .figs [num ]
70
+ del cls .figs [num ]
71
71
manager .destroy ()
72
72
gc .collect (1 )
73
73
74
- @staticmethod
75
- def destroy_fig (fig ):
74
+ @classmethod
75
+ def destroy_fig (cls , fig ):
76
76
"*fig* is a Figure instance"
77
77
num = None
78
- for manager in six .itervalues (Gcf .figs ):
78
+ for manager in six .itervalues (cls .figs ):
79
79
if manager .canvas .figure == fig :
80
80
num = manager .num
81
81
break
82
82
if num is not None :
83
- Gcf .destroy (num )
83
+ cls .destroy (num )
84
84
85
- @staticmethod
86
- def destroy_all ():
87
- for manager in list (Gcf .figs .values ()):
85
+ @classmethod
86
+ def destroy_all (cls ):
87
+ for manager in list (cls .figs .values ()):
88
88
manager .canvas .mpl_disconnect (manager ._cidgcf )
89
89
manager .destroy ()
90
90
91
- Gcf ._activeQue = []
92
- Gcf .figs .clear ()
91
+ cls ._activeQue = []
92
+ cls .figs .clear ()
93
93
gc .collect (1 )
94
94
95
- @staticmethod
96
- def has_fignum (num ):
95
+ @classmethod
96
+ def has_fignum (cls , num ):
97
97
"""
98
98
Return *True* if figure *num* exists.
99
99
"""
100
- return num in Gcf .figs
100
+ return num in cls .figs
101
101
102
- @staticmethod
103
- def get_all_fig_managers ():
102
+ @classmethod
103
+ def get_all_fig_managers (cls ):
104
104
"""
105
105
Return a list of figure managers.
106
106
"""
107
- return list (Gcf .figs .values ())
107
+ return list (cls .figs .values ())
108
108
109
- @staticmethod
110
- def get_num_fig_managers ():
109
+ @classmethod
110
+ def get_num_fig_managers (cls ):
111
111
"""
112
112
Return the number of figures being managed.
113
113
"""
114
- return len (Gcf .figs .values ())
114
+ return len (cls .figs .values ())
115
115
116
- @staticmethod
117
- def get_active ():
116
+ @classmethod
117
+ def get_active (cls ):
118
118
"""
119
119
Return the manager of the active figure, or *None*.
120
120
"""
121
- if len (Gcf ._activeQue ) == 0 :
121
+ if len (cls ._activeQue ) == 0 :
122
122
return None
123
123
else :
124
- return Gcf ._activeQue [- 1 ]
124
+ return cls ._activeQue [- 1 ]
125
125
126
- @staticmethod
127
- def set_active (manager ):
126
+ @classmethod
127
+ def set_active (cls , manager ):
128
128
"""
129
129
Make the figure corresponding to *manager* the active one.
130
130
"""
131
- oldQue = Gcf ._activeQue [:]
132
- Gcf ._activeQue = []
131
+ oldQue = cls ._activeQue [:]
132
+ cls ._activeQue = []
133
133
for m in oldQue :
134
134
if m != manager :
135
- Gcf ._activeQue .append (m )
136
- Gcf ._activeQue .append (manager )
137
- Gcf .figs [manager .num ] = manager
135
+ cls ._activeQue .append (m )
136
+ cls ._activeQue .append (manager )
137
+ cls .figs [manager .num ] = manager
138
138
139
139
140
140
atexit .register (Gcf .destroy_all )
0 commit comments