Revision: 6943
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6943&view=rev
Author: efiring
Date: 2009-02-28 07:46:14 +0000 (Sat, 28 Feb 2009)
Log Message:
-----------
Add documentation, style updates to _pylab_helpers.py
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/_pylab_helpers.py
Modified: trunk/matplotlib/lib/matplotlib/_pylab_helpers.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/_pylab_helpers.py 2009-02-27 13:32:10 UTC
(rev 6942)
+++ trunk/matplotlib/lib/matplotlib/_pylab_helpers.py 2009-02-28 07:46:14 UTC
(rev 6943)
@@ -1,3 +1,7 @@
+"""
+Manage figures for pyplot interface.
+"""
+
import sys, gc
def error_msg(msg):
@@ -4,56 +8,100 @@
print >>sys.stderr, msgs
class Gcf(object):
+ """
+ Manage a set of integer-numbered figures.
+
+ This class is never instantiated; it consists of two class
+ attributes (a list and a dictionary), and a set of static
+ methods that operate on those attributes, accessing them
+ directly as class attributes.
+
+ Attributes:
+
+ *figs*:
+ dictionary of the form {*num*: *manager*, ...}
+
+ *_activeQue*:
+ list of *managers*, with active one at the end
+
+ """
_activeQue = []
figs = {}
+ @staticmethod
def get_fig_manager(num):
+ """
+ If figure manager *num* exists, make it the active
+ figure and return the manager; otherwise return *None*.
+ """
figManager = Gcf.figs.get(num, None)
- if figManager is not None: Gcf.set_active(figManager)
+ if figManager is not None:
+ Gcf.set_active(figManager)
return figManager
- get_fig_manager = staticmethod(get_fig_manager)
+ @staticmethod
def destroy(num):
+ """
+ Try to remove all traces of figure *num*.
+ In the interactive backends, this is bound to the
+ window "destroy" and "delete" events.
+ """
if not Gcf.has_fignum(num): return
figManager = Gcf.figs[num]
+ # There must be a good reason for the following careful
+ # rebuilding of the activeQue; what is it?
oldQue = Gcf._activeQue[:]
Gcf._activeQue = []
for f in oldQue:
- if f != figManager: Gcf._activeQue.append(f)
+ if f != figManager:
+ Gcf._activeQue.append(f)
del Gcf.figs[num]
#print len(Gcf.figs.keys()), len(Gcf._activeQue)
figManager.destroy()
gc.collect()
- destroy = staticmethod(destroy)
-
+ @staticmethod
def has_fignum(num):
+ """
+ Return *True* if figure *num* exists.
+ """
return num in Gcf.figs
- has_fignum = staticmethod(has_fignum)
+ @staticmethod
def get_all_fig_managers():
+ """
+ Return a list of figure managers.
+ """
return Gcf.figs.values()
- get_all_fig_managers = staticmethod(get_all_fig_managers)
+ @staticmethod
def get_num_fig_managers():
+ """
+ Return the number of figures being managed.
+ """
return len(Gcf.figs.values())
- get_num_fig_managers = staticmethod(get_num_fig_managers)
-
+ @staticmethod
def get_active():
+ """
+ Return the manager of the active figure, or *None*.
+ """
if len(Gcf._activeQue)==0:
return None
else: return Gcf._activeQue[-1]
- get_active = staticmethod(get_active)
+ @staticmethod
def set_active(manager):
+ """
+ Make the figure corresponding to *manager* the active one.
+ """
oldQue = Gcf._activeQue[:]
Gcf._activeQue = []
for m in oldQue:
if m != manager: Gcf._activeQue.append(m)
Gcf._activeQue.append(manager)
Gcf.figs[manager.num] = manager
- set_active = staticmethod(set_active)
+
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins