Menu

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

Download this file

46 lines (32 with data), 831 Bytes

 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
#!/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()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.