basti
April 27, 2017, 9:03pm
1
I have a very basic question:
When I find a class using the documentation, for example: http://apidocs.slicer.org/master/classqMRMLSegmentEditorWidget.html
How can I know how import this class in my Python Module? For example to import the class behind the link I figured out I need write:
import qSlicerSegmentationsModuleWidgetsPythonQt
self.editor = qSlicerSegmentationsModuleWidgetsPythonQt.qMRMLSegmentEditorWidget()
Is there a way to get this information from the documentation for other classes?
pieper
(Steve Pieper (Isomics, Inc.))
April 27, 2017, 9:18pm
2
These are pulled into the slicer module, so you can access it like this:
>>> slicer.qMRMLSegmentEditorWidget()
From python you can get the API documentation (basically like doxygen) like this:
>>> help(slicer.qMRMLSegmentEditorWidget)
is that what you were looking for?
basti
April 27, 2017, 9:29pm
3
Thanks for the fast answer!
My problem is, for example, when I try to acces qSlicerSegmentationsModuleWidget by using:
slicer.qSlicerSegmentationsModuleWidget()
It tells me
‘module’ object has no attribute ‘qSlicerSegmentationsModuleWidget’
lassoan
(Andras Lasso)
April 27, 2017, 10:19pm
4
qSlicerSegmentationsModuleWidget is for exclusive use of the Segmentations module. It is built from reusable widgets that you can put in your own module widget. You can have a look at the widget’s source code and .ui file to see exactly which widgets are used and how.