|
From: <ry...@us...> - 2010-04-16 18:32:59
|
Revision: 8235
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8235&view=rev
Author: ryanmay
Date: 2010-04-16 18:32:53 +0000 (Fri, 16 Apr 2010)
Log Message:
-----------
Add a generic close event that notifies when the figure has been closed. Useful for disable other thing like timers when figure is closed.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backend_bases.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-04-16 14:28:06 UTC (rev 8234)
+++ trunk/matplotlib/CHANGELOG 2010-04-16 18:32:53 UTC (rev 8235)
@@ -1,3 +1,5 @@
+2010-04-16 Add a close_event to the backends. -RM
+
2010-04-06 modify axes_grid examples to use axes_grid1 and axisartist. -JJL
2010-04-06 rebase axes_grid using axes_grid1 and axisartist modules. -JJL
@@ -2,3 +4,3 @@
-2010-04-06 axes_grid toolkit is splitted into two separate modules,
+2010-04-06 axes_grid toolkit is splitted into two separate modules,
axes_grid1 and axisartist. -JJL
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-04-16 14:28:06 UTC (rev 8234)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-04-16 18:32:53 UTC (rev 8235)
@@ -920,6 +920,16 @@
Event.__init__(self, name, canvas)
self.width, self.height = canvas.get_width_height()
+class CloseEvent(Event):
+ """
+ An event triggered by a figure being closed
+
+ In addition to the :class:`Event` attributes, the following event attributes are defined:
+ """
+ def __init__(self, name, canvas, guiEvent=None):
+ Event.__init__(self, name, canvas, guiEvent)
+ print 'Initing CloseEvent'
+
class LocationEvent(Event):
"""
A event that has a screen location
@@ -1157,7 +1167,8 @@
'figure_enter_event',
'figure_leave_event',
'axes_enter_event',
- 'axes_leave_event'
+ 'axes_leave_event',
+ 'close_event'
]
@@ -1293,6 +1304,15 @@
event = ResizeEvent(s, self)
self.callbacks.process(s, event)
+ def close_event(self, guiEvent=None):
+ """
+ This method will be called by all functions connected to the
+ 'close_event' with a :class:`CloseEvent`
+ """
+ s = 'close_event'
+ event = CloseEvent(s, self, guiEvent=guiEvent)
+ self.callbacks.process(s, event)
+
def key_press_event(self, key, guiEvent=None):
"""
This method will be call all functions connected to the
@@ -1742,6 +1762,7 @@
- 'figure_leave_event',
- 'axes_enter_event',
- 'axes_leave_event'
+ - 'close_event'
For the location events (button and key press/release), if the
mouse is over the axes, the variable ``event.inaxes`` will be
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|