<div dir="ltr">Thanks Jonathan :)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 9, 2015 at 10:09 AM, Perdomo, Jonathan <span dir="ltr"><<a href="mailto:jonathan_perdomo@med.unc.edu" target="_blank">jonathan_perdomo@med.unc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Jean-Christophe,
<div><br>
Thank you for the response, it was very helpful.<span class="HOEnZb"><font color="#888888"><br>
<div><br>
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma">
<div style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div name="divtagdefaultwrapper" style="margin:0px">
<div style="font-size:16px;font-family:Calibri,Arial,Helvetica,sans-serif;margin-top:0px;margin-bottom:0px">
</div>
<div style="margin-top:0px;margin-bottom:0px">
<div style="font-size:16px;margin-top:0px;margin-bottom:0px;background-color:rgb(255,255,255)">
<span style="font-size:10pt">Jonathan Perdomo</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</font></span><div style="font-family:Times New Roman;color:#000000;font-size:16px"><span class="HOEnZb"><font color="#888888">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Jean-Christophe Fillion-Robin [<a href="mailto:jchris.fillionr@kitware.com" target="_blank">jchris.fillionr@kitware.com</a>]<br>
<b>Sent:</b> Tuesday, December 08, 2015 9:25 PM<br>
<b>To:</b> Perdomo, Jonathan<br>
<b>Cc:</b> <a href="mailto:ctk-developers@public.kitware.com" target="_blank">ctk-developers@public.kitware.com</a><br>
<b>Subject:</b> Re: [Ctk-developers] Observing signals in a CTK widget<br>
</font><br>
</div></font></span><div><div class="h5">
<div></div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi Jonathan, <br>
<br>
</div>
<div>And here is the answer I had in my draft box ... <br>
</div>
<div><br>
</div>
Looking at this example will tell you how to connect the signal of an object to a python function.<br>
</div>
See [1]<br>
<br>
</div>
Similarly, you should be able to connect to a coordinate widget using the signal "coordinatesChanged(double *)"<br>
</div>
See [2]<br>
<br>
</div>
<div>For example:<br>
<br>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">>>> import ctk</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">>>> w = ctk.ctkCoordinatesWidget()</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">>>> w.show()</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">>>> def onCoordindateChanged():</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">... print(w.coordinates)</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">...
</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">>>> w.connect('coordinatesChanged(double*)', onCoordindateChanged)</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">True</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">>>> 1,0,0</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span><span style="font-family:"Courier";font-size:9pt;color:rgb(0,0,150)">8<---</span></p>
<br>
<br>
</div>
<div>All of that said, we should look into an other signal of the following form:<br>
<br>
  coordinatesChanged(const QVector3D& coordinates)<br>
<br>
</div>
<div>that would be wrapped in Python.<br>
</div>
<div><br>
</div>
<div>Hth<br>
</div>
<div>Jc<br>
</div>
<div>
<div>
<div><br>
[1] <a href="https://github.com/Slicer/Slicer/blob/75fc96bf05e65659eb5204f47b5205442cc6fd8e/Extensions/Testing/ScriptedLoadableExtensionTemplate/ScriptedLoadableModuleTemplate/ScriptedLoadableModuleTemplate.py#L111-L114" target="_blank">
https://github.com/Slicer/Slicer/blob/75fc96bf05e65659eb5204f47b5205442cc6fd8e/Extensions/Testing/ScriptedLoadableExtensionTemplate/ScriptedLoadableModuleTemplate/ScriptedLoadableModuleTemplate.py#L111-L114</a><br>
<br>
[2] <a href="http://www.commontk.org/docs/html/classctkCoordinatesWidget.html#a0de7bec85eadf564e911d5c97679f4b9" target="_blank">
http://www.commontk.org/docs/html/classctkCoordinatesWidget.html#a0de7bec85eadf564e911d5c97679f4b9</a><br>
<br>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Dec 8, 2015 at 8:00 PM, Perdomo, Jonathan <span dir="ltr">
<<a href="mailto:jonathan_perdomo@med.unc.edu" target="_blank">jonathan_perdomo@med.unc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><span style="font-size:10pt">Hello everyone,</span><br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">
<div><br>
</div>
<div>I hope this question has not been asked before, but I am just trying to add an observer to my CTK coordinates widget, so that I know whether or not the values have been modified by the user. I am writing this in Python as an extension for 3D Slicer. Any
 example of how to add an observer to a widget in Python would be very helpful, as well as any sample code you may have, or resources you know of!</div>
<div><br>
</div>
<div>Thank you for your help,</div>
<div><br>
<div style="font-family:Tahoma;font-size:13px">
<div style="font-family:Tahoma">
<div style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div name="divtagdefaultwrapper" style="margin:0px">
<div style="font-size:16px;font-family:Calibri,Arial,Helvetica,sans-serif;margin-top:0px;margin-bottom:0px">
</div>
<div style="margin-top:0px;margin-bottom:0px">
<div style="font-size:16px;margin-top:0px;margin-bottom:0px;background-color:rgb(255,255,255)">
<span style="font-size:10pt">Jonathan Perdomo<br>
</span></div>
<div style="margin-top:0px;margin-bottom:0px;background-color:rgb(255,255,255)">
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Ctk-developers mailing list<br>
<a href="mailto:Ctk-developers@public.kitware.com" target="_blank">Ctk-developers@public.kitware.com</a><br>
<a href="http://public.kitware.com/mailman/listinfo/ctk-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/ctk-developers</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div><a href="tel:%2B1%20919%20869%208849" value="+19198698849" target="_blank">+1 919 869 8849</a><br>
</div>
</div>
</div>
</div></div></div>
</div>
</div>
</div>

</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">+1 919 869 8849<br></div>
</div>