Browse Source

Added python package "ctk", "ctkvtk" and "ctkqt"

ctk: This package contains all wrapped ctk classes

ctkqt: This package contains all qt classes corresponding to the qt module
enabled using the option CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT{GUI, CORE, ... }

ctkvtk: This package contains all vtk classes and constant
Jean-Christophe Fillion-Robin 14 years ago
parent
commit
271524851f

+ 2 - 0
Libs/Scripting/Python/Core/CMakeLists.txt

@@ -69,6 +69,8 @@ ctkMacroBuildLib(
 # Plugins
 #ADD_SUBDIRECTORY(Plugins)
 
+ADD_SUBDIRECTORY(Python)
+
 # Testing
 IF(BUILD_TESTING)
   #ADD_SUBDIRECTORY(Testing)

+ 44 - 0
Libs/Scripting/Python/Core/Python/CMakeLists.txt

@@ -0,0 +1,44 @@
+
+
+SET(KIT_PYTHON_SCRIPTS
+  ctkqt/__init__
+  )
+  
+IF(CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
+  LIST(APPEND KIT_PYTHON_SCRIPTS ctkvtk/__init__)
+ENDIF()
+
+IF(CTK_WRAP_PYTHONQT_LIGHT OR CTK_WRAP_PYTHONQT_FULL)
+
+  # Configure variable CTK_PYTHON_WRAPPED_LIBRARIES that will contain
+  # the comma separated list of package to load
+  SET(CTK_PYTHON_WRAPPED_LIBRARIES)
+  FOREACH(lib ${CTK_LIBS})
+    ctkFunctionExtractOptionNameAndValue(${lib} lib_name lib_value)
+    IF(${CTK_LIB_${lib_name}})
+      STRING(REPLACE "/" "" lib_name_no_slash ${lib_name})
+      SET(lib_name_no_slash "'${lib_name_no_slash}'") # Add single quotes
+      SET(CTK_PYTHON_WRAPPED_LIBRARIES "${lib_name_no_slash}, ${CTK_PYTHON_WRAPPED_LIBRARIES}")
+    ENDIF()
+  ENDFOREACH()
+
+  CONFIGURE_FILE(
+    ctk/__init__.py.in
+    ${CMAKE_CURRENT_BINARY_DIR}/ctk/__init__.py
+    @ONLY
+    )
+
+  LIST(APPEND KIT_PYTHON_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/ctk/__init__.py)
+ENDIF()
+
+SET(KIT_PYTHON_RESOURCES
+  )
+
+ctkMacroCompilePythonScript(
+  TARGET_NAME ${PROJECT_NAME}
+  SCRIPTS "${KIT_PYTHON_SCRIPTS}"
+  RESOURCES "${KIT_PYTHON_RESOURCES}"
+  DESTINATION_DIR ${CTK_BINARY_DIR}/bin/Python
+  INSTALL_DIR ${CTK_INSTALL_BIN_DIR}
+  )
+  

+ 13 - 0
Libs/Scripting/Python/Core/Python/ctk/__init__.py.in

@@ -0,0 +1,13 @@
+""" This module loads all the classes from the wrapped CTK libraries into
+its namespace."""
+
+__kits_to_load = [ @CTK_PYTHON_WRAPPED_LIBRARIES@ ]
+
+for kit in __kits_to_load:
+  try:
+    exec "from PythonQt.CTK%s import *" % (kit)
+  except ImportError as detail:
+    print detail
+   
+# Removing things the user shouldn't have to see.
+del __kits_to_load

+ 24 - 0
Libs/Scripting/Python/Core/Python/ctkqt/__init__.py

@@ -0,0 +1,24 @@
+""" This module loads all the classes from the wrapped Qt libraries into
+its namespace."""
+
+__kits_to_load = [
+'Core',
+'Gui', 
+'Network', 
+'OpenGL', 
+'Sql',
+'Svg',
+'UiTools',
+'WebKit',
+'Xml', 
+'XmlPatterns'
+]
+
+for kit in __kits_to_load:
+   try:
+     exec "from PythonQt.Qt%s import *" % (kit)
+   except ImportError as detail:
+     print detail
+   
+# Removing things the user shouldn't have to see.
+del __kits_to_load

+ 30 - 0
Libs/Scripting/Python/Core/Python/ctkvtk/__init__.py

@@ -0,0 +1,30 @@
+""" This module loads a subset of the VTK classes into its namespace."""
+
+import os
+
+__kits_to_load = [
+"Common",
+"Filtering",
+"Rendering",
+"Graphics",
+"Hybrid",
+"Views",
+"Infovis",
+"Widgets",
+"Imaging",
+"IO"]
+
+prefix = 'vtk'
+if os.name == 'posix': prefix = "libvtk"
+
+for kit in __kits_to_load:
+  try:
+    exec "from %s%sPython import *" % (prefix, kit)
+  except ImportError as detail:
+     print detail
+  
+from vtk.util.vtkVariant import *
+from vtk import vtkImageScalarTypeNameMacro
+
+# Removing things the user shouldn't have to see.
+del __kits_to_load, os