'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'

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

'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'

Gaiajack
According to the tutorials and example code, you can create a vtkCallbackCommand() object and then call SetCallback on it with a callback function, as in:

  vtkSmartPointer<vtkCallbackCommand> keypressCallback = 
      vtkSmartPointer<vtkCallbackCommand>::New();
  keypressCallback->SetCallback ( func );
However, when I try this with Python, I get 'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'. I'm using vtk 8:

def onClick():
    print("Hello, World!")

onClickCallback = vtk.vtkCallbackCommand()
onClickCallback.SetCallback(onClick)


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: 'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'

Jean-Christophe Fillion-Robin
Hi,

Thanks for reaching out.

In python, you shouldn't have to create a vtkCallbackCommand object. You can directly pass a python function to the AddObserver function.



To more easily manage the connections, you could also create a VTKObservationMixin class.

More detail about the mixin looking at these:


Hth
Jc


On Mon, Jul 9, 2018 at 7:08 AM, J. <[hidden email]> wrote:
According to the tutorials and example code, you can create a vtkCallbackCommand() object and then call SetCallback on it with a callback function, as in:

  vtkSmartPointer<vtkCallbackCommand> keypressCallback = 
      vtkSmartPointer<vtkCallbackCommand>::New();
  keypressCallback->SetCallback ( func );
However, when I try this with Python, I get 'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'. I'm using vtk 8:

def onClick():
    print("Hello, World!")

onClickCallback = vtk.vtkCallbackCommand()
onClickCallback.SetCallback(onClick)


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers




--
+1 919 869 8849

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: 'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'

Andrew Maclean-3
In reply to this post by Gaiajack
This example should give you some ideas about how to set up callbacks:

Also look at:

Regards
   Andrew


---------- Forwarded message ----------
From: 
​​
Jean-Christophe Fillion-Robin <[hidden email]>
To: "J." <[hidden email]>
Cc: [hidden email]
Bcc: 
Date: Mon, 9 Jul 2018 11:58:32 -0400
Subject: Re: [vtkusers] 'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'
Hi,

Thanks for reaching out.

In python, you shouldn't have to create a vtkCallbackCommand object. You can directly pass a python function to the AddObserver function.



To more easily manage the connections, you could also create a VTKObservationMixin class.

More detail about the mixin looking at these:


Hth
Jc


On Mon, Jul 9, 2018 at 7:08 AM, J. <[hidden email]> wrote:
According to the tutorials and example code, you can create a vtkCallbackCommand() object and then call SetCallback on it with a callback function, as in:

  vtkSmartPointer<vtkCallbackCommand> keypressCallback = 
      vtkSmartPointer<vtkCallbackCommand>::New();
  keypressCallback->SetCallback ( func );
However, when I try this with Python, I get 'vtkCommonCorePython.vtkCallbackCommand' object has no attribute 'SetCallback'. I'm using vtk 8:

def onClick():
    print("Hello, World!")

onClickCallback = vtk.vtkCallbackCommand()
onClickCallback.SetCallback(onClick)


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers




--
+1 919 869 8849
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers


--
___________________________________________
Andrew J. P. Maclean

___________________________________________

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers