|
From: <ry...@us...> - 2010-04-20 20:23:06
|
Revision: 8259
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8259&view=rev
Author: ryanmay
Date: 2010-04-20 20:23:00 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
Add example using new generic timer support and update ChangeLog.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
Added Paths:
-----------
trunk/matplotlib/examples/event_handling/timers.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-04-20 20:02:38 UTC (rev 8258)
+++ trunk/matplotlib/CHANGELOG 2010-04-20 20:23:00 UTC (rev 8259)
@@ -1,3 +1,8 @@
+2010-04-20 Added generic support for connecting to a timer for events. This
+ adds TimerBase, TimerGTK, TimerQT, TimerWx, and TimerTk to
+ the backends and a new_timer() method to each backend's
+ canvas to allow ease of creating a new timer. - RM
+
2010-04-20 Added margins() Axes method and pyplot function. - EF
2010-04-18 update the axes_grid documentation. -JJL
Added: trunk/matplotlib/examples/event_handling/timers.py
===================================================================
--- trunk/matplotlib/examples/event_handling/timers.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/timers.py 2010-04-20 20:23:00 UTC (rev 8259)
@@ -0,0 +1,30 @@
+# Simple example of using general timer objects. This is used to update
+# the time placed in the title of the figure.
+import matplotlib.pyplot as plt
+import numpy as np
+from datetime import datetime
+
+def update_title(axes):
+ axes.set_title(datetime.now())
+ axes.figure.canvas.draw()
+
+fig = plt.figure()
+ax = fig.add_subplot(1, 1, 1)
+
+x = np.linspace(-3, 3)
+ax.plot(x, x*x)
+
+# Create a new timer object. Set the interval 500 milliseconds (1000 is default)
+# and tell the timer what function should be called.
+timer = fig.canvas.new_timer()
+timer.interval = 100
+timer.add_callback(update_title, ax)
+timer.start()
+
+#Or could start the timer on first figure draw
+#def start_timer(evt):
+# timer.start()
+# fig.canvas.mpl_disconnect(drawid)
+#drawid = fig.canvas.mpl_connect('draw_event', start_timer)
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|