<div dir="ltr"><div>Hi, <br></div><div><br></div><div>Thanks for reaching out.</div><div><br></div><div>In python, you shouldn't have to create a vtkCallbackCommand object. You can directly pass a python function to the AddObserver function.<br></div><div><br></div><div>Looking at this test should help give more details: <a href="https://github.com/Kitware/VTK/blob/90f7e9a4590922d159ed3c599d0e363edcad3ed5/Common/Core/Testing/Python/TestInvokeEvent.py">https://github.com/Kitware/VTK/blob/90f7e9a4590922d159ed3c599d0e363edcad3ed5/Common/Core/Testing/Python/TestInvokeEvent.py</a></div><div><br></div><div><br></div><div>To more easily manage the connections, you could also create a <a href="https://github.com/Slicer/Slicer/blob/3ea26dae3e461899f8ecf51ec7ae02f7bab10d15/Base/Python/slicer/util.py#L932">VTKObservationMixin</a> class.<br></div><div><br></div><div>More detail about the mixin looking at these:</div><div>* <a href="https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#How_can_I_access_callData_argument_in_a_VTK_object_observer_callback_function">https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#How_can_I_access_callData_argument_in_a_VTK_object_observer_callback_function</a></div><div>* <a href="https://github.com/Slicer/Slicer/blob/3ea26dae3e461899f8ecf51ec7ae02f7bab10d15/Base/Python/slicer/tests/test_slicer_util_VTKObservationMixin.py">https://github.com/Slicer/Slicer/blob/3ea26dae3e461899f8ecf51ec7ae02f7bab10d15/Base/Python/slicer/tests/test_slicer_util_VTKObservationMixin.py</a><br></div><div><br></div><div><br></div><div>Hth</div><div>Jc<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 9, 2018 at 7:08 AM, J. <span dir="ltr"><<a href="mailto:babybishops@gmail.com" target="_blank">babybishops@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>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:</div><div><br></div><div>
<pre class="m_-1533427813086379359gmail-de1"> vtkSmartPointer<span class="m_-1533427813086379359gmail-sy1"><</span>vtkCallbackCom<wbr>mand<span class="m_-1533427813086379359gmail-sy1">></span> keypressCallback <span class="m_-1533427813086379359gmail-sy1">=</span>
vtkSmartPointer<span class="m_-1533427813086379359gmail-sy1"><</span>vtkCallbackCom<wbr>mand<span class="m_-1533427813086379359gmail-sy1">></span><span class="m_-1533427813086379359gmail-sy4">::</span><span class="m_-1533427813086379359gmail-me2">New</span><span class="m_-1533427813086379359gmail-br0">(</span><span class="m_-1533427813086379359gmail-br0">)</span><span class="m_-1533427813086379359gmail-sy4">;</span>
keypressCallback<span class="m_-1533427813086379359gmail-sy2">-</span><span class="m_-1533427813086379359gmail-sy1">></span>SetCallback <span class="m_-1533427813086379359gmail-br0">(</span> func <span class="m_-1533427813086379359gmail-br0">)</span><span class="m_-1533427813086379359gmail-sy4">;</span></pre>
</div><div>However, when I try this with Python, I get<i> 'vtkCommonCorePython.<wbr>vtkCallbackCommand' object has no attribute 'SetCallback'</i>. I'm using vtk 8:</div><div><br></div><div>
<div style="color:rgb(51,51,51);background-color:rgb(245,245,245);font-family:Consolas,"Courier New",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(122,62,157)">def</span><span style="color:rgb(51,51,51)"> </span><span style="color:rgb(170,55,49);font-weight:bold">onClick</span><span style="color:rgb(119,119,119)">():</span></div><div><span style="color:rgb(51,51,51)"> </span><span style="color:rgb(170,55,49);font-weight:bold">print</span><span style="color:rgb(119,119,119)">(</span><span style="color:rgb(119,119,119)">"</span><span style="color:rgb(68,140,39)">Hello, World!</span><span style="color:rgb(119,119,119)">"</span><span style="color:rgb(119,119,119)">)</span></div><br><div><span style="color:rgb(51,51,51)">onClickCallback </span><span style="color:rgb(119,119,119)">=</span><span style="color:rgb(51,51,51)"> vtk</span><span style="color:rgb(119,119,119)">.</span><span style="color:rgb(51,51,51)">vtkCallbackCommand</span><span style="color:rgb(119,119,119)">()</span></div><div><span style="color:rgb(51,51,51)">onClickCallback</span><span style="color:rgb(119,119,119)">.</span><span style="color:rgb(51,51,51)">SetCallback</span><span style="color:rgb(119,119,119)">(</span><span style="color:rgb(51,51,51)">on<wbr>Click</span><span style="color:rgb(119,119,119)">)</span></div></div>
<br></div></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">+1 919 869 8849<br></div>
</div>