[vtkusers] Pseudo Animation Freezes Interactor

Mischa Thesberg mejthesb at swri.ca
Fri Sep 30 12:01:21 EDT 2005


Yu-Xi Lim wrote:

> Mischa Thesberg wrote:
>
>> I managed to properly texture my cone and now I have the image on the 
>> cone changing every couple of milliseconds (which it needs to do) to 
>> make it seem like a movie is being projected on the cone (it is 
>> really a sequence of jpeg's).  The problem is while this repainting 
>> is happening (which is always) the interactor is frozen by an hour 
>> glass and I can't move or interact with the cone/actor which is 
>> important.  My animation loop works as such:
>>
>>        for i in range(100,260):
>>            time.sleep(0.03)
>>            givable = "C:/Conics/1-32-04/9-28-2005 1-32-04 PM-0%d" % 
>> i+".jpg"  #cycle through the sequentially named jpegs
>>            jpgReader.SetFileName(givable)
>>            atext.SetInput(jpgReader.GetOutput())
>>            renWin.Render()
>>
>> How do I make it so that the interactor is completely usable as this 
>> stream of jpegs is being written onto it?  Hopefully it doesn't 
>> involve complicated threading.  Any help is appreciated.  Thank You
>
>
> I guess you figured out, sleep disables the GUI while it's sleeping.
> You'd probably want to use some kind of timer with a callback, and
> unfortunately, it isn't as straightforward as using sleep. And yes, it
> involves threads, but I don't think it's too complicated.
>
> I'm assuming you aren't using a GUI toolkit like wx or Tk? Check the
> python docs on the threading module, specifically the Timer class. Just
> off the top of my head, it may look something like this:
>
> import threading
>
> def animate():
>     # do relevant jpeg changing steps here
>
> t = threading.Timer(0.1, animate) # call animate after 0.1 seconds
> t.start()


The thing is if I take the time object out and don't put a delay the 
hour glass goes away but I still can't interact with the interactor




More information about the vtkusers mailing list