Timers in Python Interactive Modules

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Timers in Python Interactive Modules

Ali Uneri
Hello,

I'm trying to develop a Slicer Interactive module in Python, where I
require to perform a periodic task which will in turn update the
module. More specifically a value is read from an external device,
after which both the GUI and scene will need to be updated.

I've used vtkKWTkUtilities::CreateTimerHandler in the C++
implementation of the module, however could not use this in Python as
(I suspect) the last argument which takes the callback method as a
string is not recognized in Python, i.e.

self.utility = slicer.vtkKWTkUtilities()
self.utility.CreateTimerHandler(self.GetApplication(), self.Interval,
self, "ProcessTimerEvents")

Is there another way to define such callback functions in Python?
Better yet, is there a way to generate timer events and utilize the
GUI observers?

Thank you,
Ali
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: [slicer-users] Timers in Python Interactive Modules

Daniel Haehn
Hi Ali,

I once used Python callbacks in connection with a vtkKWWizard.

Here is a code snippet:

...
self._wizardStepOne.SetShowUserInterfaceCommand(self.vtkScriptedModuleGUI,"Invoke
ShowUserInterface")

or you could pass arguments

self._wizardStepOne.SetShowUserInterfaceCommand(self.vtkScriptedModuleGUI,
"Invoke ShowUserInterface 'test'")

ShowUserInterface is just defined in the gui class as a
normal python method.
...

Maybe you can use something similar in connection with a timer.

HTH,
Daniel

On Wed, 20 Jan 2010 20:03:40 -0500, Ali Uneri <[hidden email]> wrote:

> Hello,
>
> I'm trying to develop a Slicer Interactive module in Python, where I
> require to perform a periodic task which will in turn update the
> module. More specifically a value is read from an external device,
> after which both the GUI and scene will need to be updated.
>
> I've used vtkKWTkUtilities::CreateTimerHandler in the C++
> implementation of the module, however could not use this in Python as
> (I suspect) the last argument which takes the callback method as a
> string is not recognized in Python, i.e.
>
> self.utility = slicer.vtkKWTkUtilities()
> self.utility.CreateTimerHandler(self.GetApplication(), self.Interval,
> self, "ProcessTimerEvents")
>
> Is there another way to define such callback functions in Python?
> Better yet, is there a way to generate timer events and utilize the
> GUI observers?
>
> Thank you,
> Ali
> _______________________________________________
> slicer-users mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
> To unsubscribe: send email to
> [hidden email] with unsubscribe as the
> subject

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject