Difference between revisions of "Events:CTK-Hackfest-2010/SlicerPythonQt"

From NAMIC Wiki
Jump to: navigation, search
(Created page with '= Overview= * All slots/property of QObject are automatically exposed to the python interpreter * Concept of decorator ** Expose regualar cpp method of QObject ** Expose object …')
 
Line 5: Line 5:
 
** Expose object and method of pure cpp classes
 
** Expose object and method of pure cpp classes
 
* Complete wrapping of all Qt Classes
 
* Complete wrapping of all Qt Classes
 +
* See http://pythonqt.sourceforge.net/
 +
 
= Implementation =
 
= Implementation =
 
* CTK Layer  
 
* CTK Layer  

Revision as of 07:01, 8 March 2010

Home < Events:CTK-Hackfest-2010 < SlicerPythonQt

Overview

  • All slots/property of QObject are automatically exposed to the python interpreter
  • Concept of decorator
    • Expose regualar cpp method of QObject
    • Expose object and method of pure cpp classes
  • Complete wrapping of all Qt Classes
  • See http://pythonqt.sourceforge.net/

Implementation

  • CTK Layer
    • qCTKConsoleWidget
    • qCTKShellPython
    • qCTKAbstractPythonManager:
      • registerPythonQtDecorator, registerClassForPythonQt, registerCPPClassForPythonQt, executeString, getVariable, executeFile, ...
      • also virtual methods: pythonPaths and preInitialization
  • Concrete example
    • Slicer superbuild download and patch SVN PythonQt head
    • Slicer CMake script pre-compile all slicer .py class
    • VTK all wrapped in python and exposed
    • qSlicerPythonManager
void qSlicerPythonManager::preInitialization()
{
  Superclass::preInitialization();

  // Register decorators
  this->registerPythonQtDecorator(new qSlicerBaseQTBasePythonQtDecorators(this));

  qSlicerCoreApplication* app = qSlicerCoreApplication::application();

  // Add object to python interpreter context
  this->addObjectToPythonMain("_qSlicerCoreApplicationInstance", app);

  // Evaluate application script
  this->executeFile(app->slicerHome() + "/bin/Python/slicer/slicerqt.py");
}