WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Winviz.exe does not "finish". (Pylab problem) (https://forum.worldviz.com/showthread.php?t=2982)

migoloco 09-23-2010 11:07 AM

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

migoloco 09-23-2010 11:42 AM

This problem was surprisingly easy to solve... all I did was:

import matplotlib
matplotlib.use('Agg')


Thank you


All times are GMT -7. The time now is 12:26 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC