[Ctk-developers] Observing signals in a CTK widget

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Wed Dec 9 15:15:48 UTC 2015


Thanks Jonathan :)

On Wed, Dec 9, 2015 at 10:09 AM, Perdomo, Jonathan <
jonathan_perdomo at med.unc.edu> wrote:

> Jean-Christophe,
>
> Thank you for the response, it was very helpful.
>
> Jonathan Perdomo
> ------------------------------
> *From:* Jean-Christophe Fillion-Robin [jchris.fillionr at kitware.com]
> *Sent:* Tuesday, December 08, 2015 9:25 PM
> *To:* Perdomo, Jonathan
> *Cc:* ctk-developers at public.kitware.com
> *Subject:* Re: [Ctk-developers] Observing signals in a CTK widget
>
> Hi Jonathan,
>
> And here is the answer I had in my draft box ...
>
> Looking at this example will tell you how to connect the signal of an
> object to a python function.
> See [1]
>
> Similarly, you should be able to connect to a coordinate widget using the
> signal "coordinatesChanged(double *)"
> See [2]
>
> For example:
>
> 8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---
> 8<---
>
> >>> import ctk
>
> >>> w = ctk.ctkCoordinatesWidget()
>
> >>> w.show()
>
> >>> def onCoordindateChanged():
>
> ... print(w.coordinates)
>
> ...
>
> >>> w.connect('coordinatesChanged(double*)', onCoordindateChanged)
>
> True
>
> >>> 1,0,0
>
> 8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---
> 8<---
>
>
> All of that said, we should look into an other signal of the following
> form:
>
>   coordinatesChanged(const QVector3D& coordinates)
>
> that would be wrapped in Python.
>
> Hth
> Jc
>
> [1]
> https://github.com/Slicer/Slicer/blob/75fc96bf05e65659eb5204f47b5205442cc6fd8e/Extensions/Testing/ScriptedLoadableExtensionTemplate/ScriptedLoadableModuleTemplate/ScriptedLoadableModuleTemplate.py#L111-L114
>
> [2]
> http://www.commontk.org/docs/html/classctkCoordinatesWidget.html#a0de7bec85eadf564e911d5c97679f4b9
>
>
> On Tue, Dec 8, 2015 at 8:00 PM, Perdomo, Jonathan <
> jonathan_perdomo at med.unc.edu> wrote:
>
>> Hello everyone,
>>
>> 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!
>>
>> Thank you for your help,
>>
>> Jonathan Perdomo
>>
>>
>> _______________________________________________
>> Ctk-developers mailing list
>> Ctk-developers at public.kitware.com
>> http://public.kitware.com/mailman/listinfo/ctk-developers
>>
>>
>
>
> --
> +1 919 869 8849
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ctk-developers/attachments/20151209/213322a0/attachment.htm>


More information about the Ctk-developers mailing list