Hello to all,<br><br>I&#39;m trying to do a recording system that catches what is happening on the interactor and writes to a file. It has to be a thread or else the interactor will be unreachable while writing the movie. I&#39;ve got the same error when I simplified the problem to just get a jpeg screenshot of the interactor when using threads. When I just call the method (
self.img.Write) I don&#39;t get this error msg and everything goes perfectly. Can someone tell me what&#39;s wrong with my code?<br><br>&nbsp;&nbsp;&nbsp; def __init__(self, parent):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from vtk import vtkConeSource, vtkPolyDataMapper, vtkActor, vtkRenderer
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # creates a dumme Cone<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.c = vtkConeSource()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.c.SetHeight(3)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.c.SetRadius(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.c.SetResolution(10)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # creates a mapper with the cone<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.m = vtkPolyDataMapper()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.m.SetInput(self.c.GetOutput())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # sets the actor with the mapper<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.a = vtkActor()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.a.SetMapper(map)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.a.SetPosition((0,0,0)) # middle of the screen
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # puts the actor inside the renderer<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.r = vtkRenderer()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.r.SetBackground((0,0,0)) # black bg<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.r.AddActor(self.a)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.r.GetActiveCamera().SetPosition((10,10,10)) # camera at some position
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # set the interactor with this renderer, attached to a wx panel<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.i = wxVTKRenderWindowInteractor(self.panel
, -1 , size = self.panel.GetSize())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.i.GetRenderWindow().AddRenderer(self.r)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.i = interactor(self.r,self.panel)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # imaging filter<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from vtk import vtkWindowToImageFilter
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.w2i = vtkWindowToImageFilter()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.w2i.SetInput(self.i.GetRenderWindow())<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # the jpeg object<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from vtk import vtkJPEGWriter<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.img = vtkJPEGWriter()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.img.SetQuality(80) # 80% is good<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.img.SetInput(self.w2i.GetOutput())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.img.SetFileName(&#39;01.jpg&#39;)<br><br>&nbsp;&nbsp;&nbsp; def OnGetPictureButton(self, event):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # threading the image writing
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from thread import start_new_thread<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start_new_thread(self.img.Write,()) # error<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # this way I don&#39;t get the error msg<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # self.img.Write()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; event.Skip()<br><br>when &quot;OnGetPictureButton&quot; is called, I get this error on a pop up screen from vtk:
<br><br>&quot;ERROR: In ..\..\VTK-5.0]\Rendering\vtkWin32OpenGLRenderWindow.cxx, lin<br>vtkWin32OpenGLRenderWindow(02FE1640): wglMakeCurrent failed in Mak&quot;<br><br>Is it some lock issue?<br><br>thx<br>