Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45cbad3

Browse files
committed
removed draft timeout/idle from backend bases; using events instead
svn path=/trunk/matplotlib/; revision=5665
1 parent 9891a69 commit 45cbad3

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

examples/event_handling/idle_and_timeout.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""
22
Demonstrate/test the idle and timeout API
3+
4+
This is only tested on gtk so far and is a prototype implementation
35
"""
46
import numpy as np
57
import matplotlib.pyplot as plt
@@ -21,23 +23,12 @@ def on_idle(event):
2123
event.canvas.draw()
2224
# test boolean return removal
2325
if on_idle.count==N:
24-
fig.canvas.mpl_disconnect(on_idle.cid)
25-
on_idle.cid = None
26-
on_idle.count = 0
27-
28-
def on_timeout(canvas):
29-
on_timeout.count +=1
30-
line2.set_ydata(np.cos(2*np.pi*t*(N-on_idle.count)/float(N)))
31-
line2.figure.canvas.draw()
32-
print 'timeout', on_timeout.count
33-
# test explicit removal
34-
if on_timeout.count==N:
3526
return False
3627
return True
37-
on_timeout.count = 0
28+
on_idle.cid = None
29+
on_idle.count = 0
3830

39-
on_idle.cid = fig.canvas.mpl_connect('idle_event', on_idle)
40-
#fig.canvas.mpl_timeout_add(100, on_timeout)
31+
fig.canvas.mpl_connect('idle_event', on_idle)
4132

4233
plt.show()
4334

0 commit comments

Comments
 (0)