Revision: 8390
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8390&view=rev
Author:   efiring
Date:     2010-06-06 22:44:18 +0000 (Sun, 06 Jun 2010)

Log Message:
-----------
[2841525] wx backend: fix classic toolbar; Figure.clf: add kwarg to keep 
axobservers

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
    trunk/matplotlib/lib/matplotlib/figure.py

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2010-06-06 
20:52:36 UTC (rev 8389)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2010-06-06 
22:44:18 UTC (rev 8390)
@@ -861,7 +861,7 @@
         simply asks for image width and margin for printing. """
 
         dmsg = """Width of output figure in inches.
-The current aspect ration will be kept."""
+The current aspect ratio will be kept."""
 
         dlg = wx.Dialog(self, -1, 'Page Setup for Printing' , (-1,-1))
         df = dlg.GetFont()
@@ -1546,8 +1546,11 @@
         return self.toolbar
 
     def Destroy(self, *args, **kwargs):
-        self.canvas.mpl_disconnect(self.toolbar._idDrag)
-        # Rationale for line above: see issue 2941338.
+        try:
+            self.canvas.mpl_disconnect(self.toolbar._idDrag)
+            # Rationale for line above: see issue 2941338.
+        except AttributeError:
+            pass # classic toolbar lacks the attribute
         wx.Frame.Destroy(self, *args, **kwargs)
         if self.toolbar is not None:
             self.toolbar.Destroy()
@@ -1707,6 +1710,8 @@
         else:
             new = True
         self._menu.Check(evt.GetId(), new)
+        # Lines above would be deleted based on svn tracker ID 2841525;
+        # not clear whether this matters or not.
         self._toolbar.set_active(self.getActiveAxes())
         evt.Skip()
 
@@ -1720,7 +1725,11 @@
                 self._menu.Append(menuId, "Axis %d" % i, "Select axis %d" % i, 
True)
                 self._menu.Check(menuId, True)
                 bind(self, wx.EVT_MENU, self._onMenuItemSelected, id=menuId)
-        self._toolbar.set_active(range(len(self._axisId)))
+        elif maxAxis < len(self._axisId):
+            for menuId in self._axisId[maxAxis:]:
+                self._menu.Delete(menuId)
+            self._axisId = self._axisId[:maxAxis]
+        self._toolbar.set_active(range(maxAxis))
 
     def getActiveAxes(self):
         """Return a list of the selected axes."""
@@ -2080,7 +2089,8 @@
 
     def update(self):
         """
-        Update the toolbar menu - called when (e.g.) a new subplot or axes are 
added
+        Update the toolbar menu - called when (e.g.) a new subplot
+        or axes are added
         """
         DEBUG_MSG("update()", 1, self)
         self._axes = self.canvas.figure.get_axes()

Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py   2010-06-06 20:52:36 UTC (rev 
8389)
+++ trunk/matplotlib/lib/matplotlib/figure.py   2010-06-06 22:44:18 UTC (rev 
8390)
@@ -691,9 +691,12 @@
         self.sca(a)
         return a
 
-    def clf(self):
+    def clf(self, keep_observers=False):
         """
-        Clear the figure
+        Clear the figure.
+
+        Set *keep_observers* to True if, for example,
+        a gui widget is tracking the axes in the figure.
         """
         self.suppressComposite = None
         self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
@@ -713,7 +716,8 @@
         self.texts=[]
         self.images = []
         self.legends = []
-        self._axobservers = []
+        if not keep_observers:
+            self._axobservers = []
 
     def clear(self):
         """


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to