[vtkusers] python + vtkTkRenderWidget + threading == X restart

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Fri May 18 07:27:51 EDT 2001


>>>>> "JVH" == Jan Vittrup Hansen <Jan.Vittrup at Person.dk> writes:

    JVH> Hi All, I seem to be unable to do threaded interaction in
    JVH> python. Therefor a small test example has been deviced, which
    JVH> on my machine (redhat71 + matrox g400 + rh7 vtk rpms) crashes
    JVH> X.  Are you daring enough to try it ;o) Seriously, I would be
    JVH> greatfull if anyone can test this using other graphics
    JVH> drivers, or tell me what I'm doing wrong :o)

Well I tried this on the interpreter

>>> from vtkpython import *
>>> from Tkinter import *
>>> from vtkRenderWidget import *
>>> import time, thread
>>> source = vtkSphereSource()
>>> mapper = vtkPolyDataMapper()
>>> mapper.SetInput(source.GetOutput())
>>> actor = vtkActor()
>>> actor.SetMapper(mapper)
>>> root = Tk()
>>> pane = vtkTkRenderWidget(root,width=300,height=300)
>>> ren = vtkRenderer()
>>> renWin = pane.GetRenderWindow()
>>> renWin.AddRenderer(ren)
>>> ren.AddActor(actor)
>>> # pack the pane into the tk root
... pane.pack (fill="both", expand=1)
>>> print "test"

and everything works fine upto this point (I can even interact with
the spehere etc.).  However, the instant I add the following it
behaves strangely.

>>> thread.start_new_thread(root.mainloop, ())

It works for a while and then hangs.  I have to ^C at the interpreter
to do anything.

I also checked to see if Tkinter was the problem, it isnt.

>>> def f (event=None):
...   print "Inside f()"
>>> from Tkinter import *
>>> root = Tk ()
>>> b = Button (root, text="Test", command=f)
>>> import thread
>>> thread.start_new_thread (root.mainloop,  ())

And everything runs fine.

BTW, I am using Debian GNU/Linux 2.2 with the VTK nightlies + Python
1.5.2 + Tcl/Tk 8.0.  Xfree86 4.0.2 with an nVidia TNT2 card and the
nVidia drivers.


More information about the vtkusers mailing list