using vtkTimerCallback with QVTKRenderWindowInteractor not working

送分小仙女□ 提交于 2019-12-07 07:18:28

Just had the same problem. As deep as I looked it appears to be a bug comming from QVTKRenderWindowInteractor class. While creating the repeating timer, the duration parameter (1000 in your example) is not taken into account and the default parameter (10) is used instead.

So to fix it I created a subclass MyQVTKRenderWindowInteractor and overwrote the methods I needed:

class MyQVTKRenderWindowInteractor(QVTKRenderWindowInteractor):
   def __init__(self, *arg):
       super(MyQVTKRenderWindowInteractor, self).__init__(*arg)
       self._TimerDuration = 10 # default value

   def CreateTimer(self, obj, event):
       self._Timer.start(self._TimerDuration) # self._Timer.start(10) in orginal

   def CreateRepeatingTimer(self, duration):
       self._TimerDuration = duration
       super(MyQVTKRenderWindowInteractor, self).GetRenderWindow().GetInteractor().CreateRepeatingTimer(duration)
       self._TimeDuration = 10

Now renderWindowInteractor = MyQVTKRenderWindowInteractor(self.frame) should work.

Hopping answer has not come to late ++

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!