anim_tk.py

来自「非原创。很好的python例子」· Python 代码 · 共 50 行

PY
50
字号
# 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.3import matplotlibmatplotlib.use('TkAgg')import pylab#import Tkinter as Tkimport matplotlib.numerix as numerixfig = 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.countupdatefig.count=-1def 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 Tkmanager.window.after(10, run)manager.show()Tk.mainloop()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?