[Ctk-developers] Python wrapper

Steve Pieper pieper at ibility.net
Mon Jul 16 10:34:10 EDT 2012


Hi Felix -

Agreed - it would be great to have be able to import CTK into a
standard python interpreter.  Perhaps you can contribute code for
that? :)

By way of background, PySide did not exist when CTK chose to use
PythonQt.  PyQt was (and still is, I believe) only available under GPL
or commercial licenses.  PythonQt is licensed under LGPL and suited
our needs well.

Now that PySide exists, using it with CTK should be possible but I
don't think anyone has looked in detail at it.

-Steve

On Mon, Jul 16, 2012 at 10:13 AM, Félix C. Morency
<felix.morency at gmail.com> wrote:
> Jean-Christophe,
>
> Thank you for your answer. I've been able to build and run CTK
> successfully. From my understanding, PythonQt has the purpose of
> bringing Python scripting capabilities to an existing Qt/C++
> application. On the other hand, PyQt/PySide applications are
> (entirely) built using Python. Therefore, I think we have to bind CTK
> using SIP (PyQt) or Shiboken (PySide) in order to use CTK widgets
> directly from PyQt/PySide.
>
> Regards,
> -Felix
>
> On Thu, Jul 12, 2012 at 7:04 PM, Jean-Christophe Fillion-Robin
> <jchris.fillionr at kitware.com> wrote:
>> Hi Felix,
>>
>> Thanks for kind compliment  and your interest in CTK :)
>>
>> When configuring CTK, if you enable the following two options:
>>
>>   CTK_BUILD_EXAMPLES
>>   CTK_ENABLE_Python_Wrapping
>>
>> an example application named "ctkSimplePythonShell" will then be built.
>>
>> Assuming you are unix-like platform, you could then simply run the
>> application using:
>>
>>    ./bin/ctkSimplePythonShell
>>
>> See enclosed screenshot for an illustration.
>>
>> Currently, CTK objects and widgets are "wrapped" leveraging PythonQt, I am
>> not sure how it could be integrated with PySide or PyQt.
>>
>> To learn more about PythonQt: https://github.com/commontk/PythonQt#readme
>>
>> All steps together:
>>
>> git clone git://github.com/commontk/CTK.git && \
>> mkdir CTK-build && \
>> cd CTK-build && \
>> cmake -DCTK_ENABLE_Python_Wrapping:BOOL=ON -DCTK_BUILD_EXAMPLES:BOOL=ON
>> -DQT_QMAKE_EXECUTABLE:FILEPATH=/home/jchris/Projects/QtSDK-1.2/Desktop/Qt/474/gcc/bin/qmake
>> ../CTK && \
>> make -j4 && \
>> cd CTK-build && \
>> ./bin/ctkSimplePythonShell
>>
>>
>> Then, within the console, you should be able to run the following command:
>>
>> import ctk
>>
>> w = ctk.ctkColorDialog()
>>
>> w.show()
>>
>>
>> If running ccmake or cmake-gui, you could also display the list of advanced
>> options and enable the following one:
>>
>>   CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTCORE
>> CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTGUI
>>
>> You will then be able to run command like:
>>
>>   import qt
>>   b = qt.QPushButton("Ciao")
>>   b.show()
>>
>> There is also possibility of interfacing CTK PythonQt and VTK by enabling:
>>
>>  CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK
>>
>>
>> Let me us know if you have additional questions.
>>
>> Thanks
>> Jc
>>
>>
>> On Thu, Jul 12, 2012 at 4:44 PM, Félix C. Morency <felix.morency at gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> First, thank you for sharing such a great piece of software. I'm
>>> writing to you because I want to know if you have any plans on
>>> developing Python wrapper for CTK? I would really like to be able to
>>> use your widget in, say, a PySide application.
>>>
>>> Regards,
>>> --
>>> Félix C. Morency, M.Sc.
>>> Plateforme d’analyse et de visualisation d’images
>>> Centre Hospitalier Universitaire de Sherbrooke
>>> Centre de recherche clinique Étienne-Le Bel
>>> Local Z5-3031 | 819.346.1110 ext 16634
>>> _______________________________________________
>>> Ctk-developers mailing list
>>> Ctk-developers at commontk.org
>>> http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers
>>
>>
>>
>>
>> --
>> +1 919 869 8849
>>
>
>
>
> --
> --
> Félix C. Morency, M.Sc.
> Plateforme d’analyse et de visualisation d’images
> Centre Hospitalier Universitaire de Sherbrooke
> Centre de recherche clinique Étienne-Le Bel
> Local Z5-3031 | 819.346.1110 ext 16634
> _______________________________________________
> Ctk-developers mailing list
> Ctk-developers at commontk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers



More information about the Ctk-developers mailing list