<div dir="ltr">Hi All, <div><br></div><div>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: <a href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/ClientData">https://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/ClientData</a></div><div><br></div><div>However, I do not know how to do that in Python.</div><div><br></div><div>Indeed, if I create a <span style="background-color:rgb(249,249,249);color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em">vtkCallbackCommand</span> , SetCallBack function does not exist.</div><div><br></div><div>Any Idea? Thanks for your answer.</div><div><br></div><div>Serge</div><div><br></div><div>ps: python36 - vtk 7.1.1</div><div> </div><div><br></div><div><pre style="box-sizing:inherit;color:rgb(55,71,79);font-feature-settings:'kern' 1;font-family:"Roboto Mono","Courier New",Courier,monospace;background-color:transparent;font-size:13.6px;margin-top:0px;margin-bottom:0px;border-radius:0.2rem;line-height:1.4;padding:1.05rem 1.2rem;overflow:auto;vertical-align:top"><span class="gmail-ch" style="box-sizing:inherit;color:rgb(153,153,153)">#!/usr/bin/env python</span>
<span class="gmail-kn" style="box-sizing:inherit;color:rgb(59,120,231)">from</span> <span class="gmail-nn" style="box-sizing:inherit;color:rgb(236,64,122)">__future__</span> <span class="gmail-kn" style="box-sizing:inherit;color:rgb(59,120,231)">import</span> <span class="gmail-n" style="box-sizing:inherit">print_function</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-kn" style="box-sizing:inherit;color:rgb(59,120,231)">import</span> <span class="gmail-nn" style="box-sizing:inherit;color:rgb(236,64,122)">vtk</span>
</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">source</span> <span class="gmail-o" style="box-sizing:inherit;color:inherit">=</span> <span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkSphereSource</span><span class="gmail-p" style="box-sizing:inherit">()</span>
</span><span class="gmail-n" style="box-sizing:inherit">source</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetCenter</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">0</span><span class="gmail-p" style="box-sizing:inherit">,</span> <span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">0</span><span class="gmail-p" style="box-sizing:inherit">,</span> <span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">0</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-n" style="box-sizing:inherit">source</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetRadius</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">1</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-n" style="box-sizing:inherit">source</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">Update</span><span class="gmail-p" style="box-sizing:inherit">()</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">mapper</span> <span class="gmail-o" style="box-sizing:inherit;color:inherit">=</span> <span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkPolyDataMapper</span><span class="gmail-p" style="box-sizing:inherit">()</span>
</span><span class="gmail-n" style="box-sizing:inherit">mapper</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetInputConnection</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">source</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">GetOutputPort</span><span class="gmail-p" style="box-sizing:inherit">())</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">actor</span> <span class="gmail-o" style="box-sizing:inherit;color:inherit">=</span> <span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkActor</span><span class="gmail-p" style="box-sizing:inherit">()</span>
</span><span class="gmail-n" style="box-sizing:inherit">actor</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetMapper</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">mapper</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">renderer</span> <span class="gmail-o" style="box-sizing:inherit;color:inherit">=</span> <span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkRenderer</span><span class="gmail-p" style="box-sizing:inherit">()</span>
</span><span class="gmail-n" style="box-sizing:inherit">renderer</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetBackground</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">1</span><span class="gmail-p" style="box-sizing:inherit">,</span> <span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">1</span><span class="gmail-p" style="box-sizing:inherit">,</span> <span class="gmail-mi" style="box-sizing:inherit;color:rgb(231,76,60)">1</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-n" style="box-sizing:inherit">renderer</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">AddActor</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">actor</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">renwin</span> <span class="gmail-o" style="box-sizing:inherit;color:inherit">=</span> <span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkRenderWindow</span><span class="gmail-p" style="box-sizing:inherit">()</span>
</span><span class="gmail-n" style="box-sizing:inherit">renwin</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">AddRenderer</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">renderer</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">interactor</span> <span class="gmail-o" style="box-sizing:inherit;color:inherit">=</span> <span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkRenderWindowInteractor</span><span class="gmail-p" style="box-sizing:inherit">()</span>
</span><span class="gmail-hll" style="box-sizing:inherit;display:block;padding:0px 1.2rem;background-color:rgba(240,240,240,0.8)"><span class="gmail-n" style="box-sizing:inherit">interactor</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetInteractorStyle</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">vtk</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">vtkInteractorStyleTrackballCamera</span><span class="gmail-p" style="box-sizing:inherit">())</span>
</span><span class="gmail-n" style="box-sizing:inherit">interactor</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">SetRenderWindow</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">renwin</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-k" style="box-sizing:inherit;color:rgb(59,120,231)">def</span> <span class="gmail-nf" style="box-sizing:inherit;color:rgb(194,24,91)">DummyFunc</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-n" style="box-sizing:inherit">obj</span><span class="gmail-p" style="box-sizing:inherit">,</span> <span class="gmail-n" style="box-sizing:inherit">ev, my_obj_2</span><span class="gmail-p" style="box-sizing:inherit">):</span>
<span class="gmail-k" style="box-sizing:inherit;color:rgb(59,120,231)">print</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-s2" style="box-sizing:inherit;color:rgb(13,144,79)">obj, my_obj_2</span><span class="gmail-p" style="box-sizing:inherit">)</span>
# obj_2 = vtk.whatever()
<span class="gmail-c1" style="box-sizing:inherit;color:rgb(153,153,153)"># How do I pass my obj_2 ? </span>
<span class="gmail-n" style="box-sizing:inherit">interactor</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">AddObserver</span><span class="gmail-p" style="box-sizing:inherit">(</span><span class="gmail-s1" style="box-sizing:inherit;color:rgb(13,144,79)">'LeftButtonPressEvent'</span><span class="gmail-p" style="box-sizing:inherit">,</span> <span class="gmail-n" style="box-sizing:inherit">DummyFunc</span><span class="gmail-p" style="box-sizing:inherit">)</span>
<span class="gmail-n" style="box-sizing:inherit">interactor</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">Initialize</span><span class="gmail-p" style="box-sizing:inherit">()</span>
<span class="gmail-n" style="box-sizing:inherit">interactor</span><span class="gmail-o" style="box-sizing:inherit;color:inherit">.</span><span class="gmail-n" style="box-sizing:inherit">Start</span><span class="gmail-p" style="box-sizing:inherit">()</span></pre></div></div>