[Ctk-developers] Python wrapper

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Thu Jul 12 19:04:06 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ctk-developers/attachments/20120712/3ef0186d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CTK-ctkSimplePythonShell-e883332.png
Type: image/png
Size: 170495 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/ctk-developers/attachments/20120712/3ef0186d/attachment-0002.png>


More information about the Ctk-developers mailing list