|
From: <jd...@us...> - 2010-01-29 15:28:03
|
Revision: 8101
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8101&view=rev
Author: jdh2358
Date: 2010-01-29 15:27:54 +0000 (Fri, 29 Jan 2010)
Log Message:
-----------
added state to legend toggle
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-01-28 21:46:12 UTC (rev 8100)
+++ trunk/matplotlib/CHANGELOG 2010-01-29 15:27:54 UTC (rev 8101)
@@ -1,3 +1,6 @@
+2010-01-29 Added draggable method to Legend to allow mouse drag
+placement. Thanks Adam Fraser. JDH
+
2010-01-25 Fixed a bug reported by Olle Engdegard, when using
histograms with stepfilled and log=True - MM
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2010-01-28 21:46:12 UTC (rev 8100)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2010-01-29 15:27:54 UTC (rev 8101)
@@ -935,16 +935,32 @@
return ox, oy
- def draggable(self):
+ def draggable(self, state=None):
"""
- toggle the draggable state; if on, you can drag the legend on
- the canvas. The DraggableLegend helper class is returned
+ Set the draggable state -- if state is
+
+ * None : toggle the current state
+
+ * True : turn draggable on
+
+ * False : turn draggable off
+
+ If draggable is on, you can drag the legend on the canvas with
+ the mouse. The DraggableLegend helper instance is returned if
+ draggable is on.
"""
- if self._draggable is not None:
- self._draggable.disconnect()
+ is_draggable = self._draggable is not None
+
+ # if state is None we'll toggle
+ if state is None:
+ state = not is_draggable
+
+ if state:
+ if self._draggable is None:
+ self._draggable = DraggableLegend(self)
+ else:
+ if self._draggable is not None:
+ self._draggable.disconnect()
self._draggable = None
- else:
- self._draggable = DraggableLegend(self)
-
return self._draggable
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|