# Import Class with Python

**URL:** <https://discourse.slicer.org/t/import-class-with-python/217>\
**Category:** Support\
**Created:** [April 27, 2017, 9:03pm UTC](https://discourse.slicer.org/t/import-class-with-python/217 "2017-04-27T21:03:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://discourse.slicer.org/u/basti)\
**Post date:** [April 27, 2017, 9:03pm UTC](https://discourse.slicer.org/t/import-class-with-python/217/1 "2017-04-27T21:03:18Z")

</div>

I have a very basic question:

When I find a class using the documentation, for example: [http://apidocs.slicer.org/master/classqMRMLSegmentEditorWidget.html](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?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 27, 2017, 9:18pm UTC](https://discourse.slicer.org/t/import-class-with-python/217/2 "2017-04-27T21:18:02Z")

</div>

These are pulled into the slicer module, so you can access it like this:

```auto
>>> slicer.qMRMLSegmentEditorWidget()

```

From python you can get the API documentation (basically like doxygen) like this:

```auto
>>> help(slicer.qMRMLSegmentEditorWidget)

```

is that what you were looking for?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://discourse.slicer.org/u/basti)\
**Post date:** [April 27, 2017, 9:29pm UTC](https://discourse.slicer.org/t/import-class-with-python/217/3 "2017-04-27T21:29:59Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 27, 2017, 10:19pm UTC](https://discourse.slicer.org/t/import-class-with-python/217/4 "2017-04-27T22:19:17Z")

</div>

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.
