Difference between revisions of "User:Inorton/Slicer4:Python"

From NAMIC Wiki
Jump to: navigation, search
Line 3: Line 3:
 
<pre>import PythonQt</pre>
 
<pre>import PythonQt</pre>
  
 
+
*PythonQt wraps vtk objects with array arguments:
 +
<pre>
 +
>>>box = vtk.vtkBox
 +
>>>bds = [0.0 for i in range(6)]
 +
>>>box.SetBounds( scene.GetNodeByID('vtkMRMLAnnotationROINode1') )
 +
>>>box.GetBounds(bds)
 +
>>>bds
 +
[-22.492652893066406, 52.710166931152344, 36.159854888916016, 36.605098724365234, 11.289838790893555, 55.752235412597656]
 +
</pre>
  
 
==Links==
 
==Links==
 
*http://zetcode.com/tutorials/pyqt4/introduction/
 
*http://zetcode.com/tutorials/pyqt4/introduction/

Revision as of 03:55, 6 February 2011

Notes

  • Uses a CMake-enabled fork of pythonqt.. not sure which version, but it doesn't import as PyQt4. Use:
import PythonQt
  • PythonQt wraps vtk objects with array arguments:
>>>box = vtk.vtkBox
>>>bds = [0.0 for i in range(6)]
>>>box.SetBounds( scene.GetNodeByID('vtkMRMLAnnotationROINode1') )
>>>box.GetBounds(bds)
>>>bds
[-22.492652893066406, 52.710166931152344, 36.159854888916016, 36.605098724365234, 11.289838790893555, 55.752235412597656]

Links