View Single Post
  #1  
Old 09-23-2010, 11:07 AM
migoloco migoloco is offline
Member
 
Join Date: Sep 2010
Posts: 5
Winviz.exe does not "finish". (Pylab problem)

Hi, I am using the following simple script to demonstrate the problem. Winviz.exe does not close from the task manager after I trigger the makeachart() by keypressing 1.

However, the same does not happen if I execute the function directly, instead of calling it through vizact.onkeydown('1', makeachart, "file.png"). Am I doing something wrong? Thanks.
import wx
import viz
#--
import matplotlib
matplotlib.use('WXAgg')
#--
import pylab

def makeachart(f):
x = pylab.arange(1961, 2031, 1)
y = pylab.sin(2 * pylab.pi * x)
pylab.plot(x, y, linewidth=2.0)
pylab.savefig(f, format='png')

vizact.onkeydown('1', makeachart, "file.png")

class VizardFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__( self,
parent,
-1,
"Vizard Embedded Example",
size=(800,600),
style=wx.DEFAULT_FRAME_STYLE )
window = wx.Window(self,-1)
viz.go(viz.EMBEDDED,window.GetHandle())
quad = viz.addTexQuad( pos=(0,1.6,5) )
quad.color(viz.RED)
quad.disable(viz.LIGHTING)
quad.addAction(vizact.spin(0,1,0,90))
self.timer = wx.Timer(self)
self.timer.Start(10)
self.Bind(wx.EVT_TIMER, self.OnTimer)

def OnTimer(self, event):
if viz.done():
self.Destroy()
return
viz.updateFrame()

if __name__ == '__main__':
app = wx.PySimpleApp()
frame = VizardFrame(None)
frame.Show(True)
app.MainLoop()
Reply With Quote