[vtkusers] SetClientData in python

Serge K. skab12 at gmail.com
Fri Nov 10 12:32:27 EST 2017


Hi All,

I am playing with MouseEventObserver.py example and I would like to add a
ClientData on my callback function. There are many examples in C++ like
this one: https://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/ClientData

However, I do not know how to do that in Python.

Indeed, if I create a  vtkCallbackCommand , SetCallBack function does not
exist.

Any Idea? Thanks for your answer.

Serge

ps: python36 - vtk 7.1.1


#!/usr/bin/env pythonfrom __future__ import print_function
import vtksource = vtk.vtkSphereSource()source.SetCenter(0, 0,
0)source.SetRadius(1)source.Update()
mapper = vtk.vtkPolyDataMapper()mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()renderer.SetBackground(1, 1,
1)renderer.AddActor(actor)
renwin = vtk.vtkRenderWindow()renwin.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())interactor.SetRenderWindow(renwin)
def DummyFunc(obj, ev, my_obj_2):
    print(obj, my_obj_2)

# obj_2 = vtk.whatever()# How do I pass my obj_2 ?
interactor.AddObserver('LeftButtonPressEvent',
DummyFunc)interactor.Initialize()interactor.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171110/4bf3c4c2/attachment.html>


More information about the vtkusers mailing list