# Change active widget

**URL:** <https://discourse.slicer.org/t/change-active-widget/36005>\
**Category:** Development\
**Created:** [May 8, 2024, 8:22pm UTC](https://discourse.slicer.org/t/change-active-widget/36005 "2024-05-08T20:22:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfajtai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dfajtai/32/70340_2.png) [@dfajtai](https://discourse.slicer.org/u/dfajtai)\
**Post date:** [May 8, 2024, 8:22pm UTC](https://discourse.slicer.org/t/change-active-widget/36005/1 "2024-05-08T20:22:37Z")

</div>

I am curious if there is a way to jump from one module to another programmatically using Python.

I have a module in which several automatic segmentations were generated. I would like to give an easy option for the user to jump into the SegmentEditor widget - which was previously configured by certain parameters - showing a certain segmentation over a given master volume.

So far I have tried this:

```auto
self.segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
self.segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
self.segmentEditorNode =slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentEditorNode")
self.segmentEditorWidget.setMRMLSegmentEditorNode(self.segmentEditorNode)

```

then later on

```auto
self.segmentEditorWidget.show()

```

but this shows the widget inside a floating window.

So the question is, what is the right way, to show a docked version of the parametrized SegmentEditorWidget?

---

<div class="post-metadata">

**Author:** ![rfenioux](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rfenioux/32/70007_2.png) [@rfenioux](https://discourse.slicer.org/u/rfenioux)\
**Post date:** [May 13, 2024, 7:53am UTC](https://discourse.slicer.org/t/change-active-widget/36005/2 "2024-05-13T07:53:10Z")

</div>

This is the expected behavior when creating a new widget, unless you integrate it into the layout of your module. I think what you want is to configure the existing segment editor widget instance, then jump to the segment editor module.

```auto
segmentEditorWidget = slicer.modules.SegmentEditorWidget.editor
# setup things ...
segmentEditorWidget.setActiveEffectByName("Threshold")

```

switch to module  
`slicer.util.selectModule("SegmentEditor")`

---

<div class="post-metadata">

**Author:** ![dfajtai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dfajtai/32/70340_2.png) [@dfajtai](https://discourse.slicer.org/u/dfajtai)\
**Post date:** [May 17, 2024, 7:53am UTC](https://discourse.slicer.org/t/change-active-widget/36005/4 "2024-05-17T07:53:48Z")

</div>

As you said this needs an existing segment editor widget. But it is instantiated only if the user opens the segment editor module previously. By opening the segment editor, 3 nodes are generated: a vtkMRMLSegmentEditorNode, a vtkMRMLSegmentationNode, and a vtkMRMLSegmentationDisplayNode.

By calling

```auto
slicer.util.selectModule("SegmentEditor")

```

later on, will show this instance of the segment editor - not the one I have instantiated manually.

So the question still remains, but a bit altered:  
How can one create all these three nodes, without opening the segment editor?

Since then I have 2 solutions: switching back and forth between the segment editor and my module, or switching to the segment editor - which ensures that there is an instance I can parameterize - and then make the changes I want to.
