anim_tk.py doesn't run

This application has requested the Runtime to terminate it

    > in an unusual way. Please contact the application's support
    > team for more information.

    > C:\Python23\Lib\site-packages\matplotlib\examples>

Hi Gary, the good news is that I could replicate the bug on XP and the
better news is that I could fix it :slight_smile:

It looks like a bug in the anim_tk script and not in matplotlib
proper. Basically, anim_tk never calls the tk mainloop. Why this
works under linux and not windows is not clear to me. The trick is to
start the tk mainloop and use the tk after handler to run a command
after x milliseconds. So I rewrote the example to do the animation in
a loop, and used the after command to start this function after the
mainloop is launched.

If you have any additional trouble, you may want to try turning off

  tk.window_focus : False # Maintain shell focus for TkAgg

in your rc file.

Hope this helps!
JDH

#!/usr/bin/env python2.3

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.matlab

#import Tkinter as Tk
import matplotlib.numerix as numerix
fig = matplotlib.matlab.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 = matplotlib.matlab.plot(X[:,0],'o')

manager = matplotlib.matlab.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):

    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()

I looked at this but couldn't solve it... way to go John!

Cheers,
Todd

···

On Mon, 2004-11-22 at 13:48, John Hunter wrote:

    > This application has requested the Runtime to terminate it
    > in an unusual way. Please contact the application's support
    > team for more information.

    > C:\Python23\Lib\site-packages\matplotlib\examples>

Hi Gary, the good news is that I could replicate the bug on XP and the
better news is that I could fix it :slight_smile: