@@ -35,106 +35,106 @@ class Gcf(object):
3535 _activeQue = []
3636 figs = {}
3737
38- @staticmethod
39- def get_fig_manager (num ):
38+ @classmethod
39+ def get_fig_manager (cls , num ):
4040 """
4141 If figure manager *num* exists, make it the active
4242 figure and return the manager; otherwise return *None*.
4343 """
44- manager = Gcf .figs .get (num , None )
44+ manager = cls .figs .get (num , None )
4545 if manager is not None :
46- Gcf .set_active (manager )
46+ cls .set_active (manager )
4747 return manager
4848
49- @staticmethod
50- def destroy (num ):
49+ @classmethod
50+ def destroy (cls , num ):
5151 """
5252 Try to remove all traces of figure *num*.
5353
5454 In the interactive backends, this is bound to the
5555 window "destroy" and "delete" events.
5656 """
57- if not Gcf .has_fignum (num ):
57+ if not cls .has_fignum (num ):
5858 return
59- manager = Gcf .figs [num ]
59+ manager = cls .figs [num ]
6060 manager .canvas .mpl_disconnect (manager ._cidgcf )
6161
6262 # There must be a good reason for the following careful
6363 # rebuilding of the activeQue; what is it?
64- oldQue = Gcf ._activeQue [:]
65- Gcf ._activeQue = []
64+ oldQue = cls ._activeQue [:]
65+ cls ._activeQue = []
6666 for f in oldQue :
6767 if f != manager :
68- Gcf ._activeQue .append (f )
68+ cls ._activeQue .append (f )
6969
70- del Gcf .figs [num ]
70+ del cls .figs [num ]
7171 manager .destroy ()
7272 gc .collect (1 )
7373
74- @staticmethod
75- def destroy_fig (fig ):
74+ @classmethod
75+ def destroy_fig (cls , fig ):
7676 "*fig* is a Figure instance"
7777 num = None
78- for manager in six .itervalues (Gcf .figs ):
78+ for manager in six .itervalues (cls .figs ):
7979 if manager .canvas .figure == fig :
8080 num = manager .num
8181 break
8282 if num is not None :
83- Gcf .destroy (num )
83+ cls .destroy (num )
8484
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 ()):
8888 manager .canvas .mpl_disconnect (manager ._cidgcf )
8989 manager .destroy ()
9090
91- Gcf ._activeQue = []
92- Gcf .figs .clear ()
91+ cls ._activeQue = []
92+ cls .figs .clear ()
9393 gc .collect (1 )
9494
95- @staticmethod
96- def has_fignum (num ):
95+ @classmethod
96+ def has_fignum (cls , num ):
9797 """
9898 Return *True* if figure *num* exists.
9999 """
100- return num in Gcf .figs
100+ return num in cls .figs
101101
102- @staticmethod
103- def get_all_fig_managers ():
102+ @classmethod
103+ def get_all_fig_managers (cls ):
104104 """
105105 Return a list of figure managers.
106106 """
107- return list (Gcf .figs .values ())
107+ return list (cls .figs .values ())
108108
109- @staticmethod
110- def get_num_fig_managers ():
109+ @classmethod
110+ def get_num_fig_managers (cls ):
111111 """
112112 Return the number of figures being managed.
113113 """
114- return len (Gcf .figs .values ())
114+ return len (cls .figs .values ())
115115
116- @staticmethod
117- def get_active ():
116+ @classmethod
117+ def get_active (cls ):
118118 """
119119 Return the manager of the active figure, or *None*.
120120 """
121- if len (Gcf ._activeQue ) == 0 :
121+ if len (cls ._activeQue ) == 0 :
122122 return None
123123 else :
124- return Gcf ._activeQue [- 1 ]
124+ return cls ._activeQue [- 1 ]
125125
126- @staticmethod
127- def set_active (manager ):
126+ @classmethod
127+ def set_active (cls , manager ):
128128 """
129129 Make the figure corresponding to *manager* the active one.
130130 """
131- oldQue = Gcf ._activeQue [:]
132- Gcf ._activeQue = []
131+ oldQue = cls ._activeQue [:]
132+ cls ._activeQue = []
133133 for m in oldQue :
134134 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
138138
139139
140140atexit .register (Gcf .destroy_all )
0 commit comments