Menu

[r4259]: / trunk / htdocs / examples / anim_tk.py  Maximize  Restore  History

Download this file

50 lines (35 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# deprecated - this example is no longer needed. Follow the model of
# anim.py to use interaction = True to avoid all the cruft of timers,
# callbacks and the likes used here
#!/usr/bin/env python2.3
import matplotlib
matplotlib.use('TkAgg')
import pylab
#import Tkinter as Tk
import matplotlib.numerix as numerix
fig = pylab.figure(1)
ind = numerix.arange(60)
x_tmp=[]
for i in range(100):
x_tmp.append(numerix.sin((ind+i)*numerix.pi/15.0))
X=numerix.array(x_tmp)
lines = pylab.plot(X[:,0],'o')
manager = pylab.get_current_fig_manager()
def updatefig(*args):
updatefig.count += 1
lines[0].set_ydata(X[:,updatefig.count%60])
manager.canvas.draw()
return updatefig.count
updatefig.count=-1
def run(*args):
print 'called run'
import time
tstart = time.time()
while 1:
cnt = updatefig()
if cnt==100: break
print 'elapsed', 100.0/(time.time() - tstart)
import Tkinter as Tk
manager.window.after(10, run)
manager.show()
Tk.mainloop()