Import Class with Python

I have a very basic question:

When I find a class using the documentation, for example:

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?

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?

Thanks for the fast answer!

My problem is, for example, when I try to acces qSlicerSegmentationsModuleWidget by using:


It tells me

‘module’ object has no attribute ‘qSlicerSegmentationsModuleWidget’

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.