# Referencing a module widget from another module

**URL:** <https://discourse.slicer.org/t/referencing-a-module-widget-from-another-module/7419>\
**Category:** Development\
**Tags:** extensions-manager\
**Created:** [July 4, 2019, 5:52pm UTC](https://discourse.slicer.org/t/referencing-a-module-widget-from-another-module/7419 "2019-07-04T17:52:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattTroke](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MattTroke](https://discourse.slicer.org/u/MattTroke)\
**Post date:** [July 4, 2019, 5:52pm UTC](https://discourse.slicer.org/t/referencing-a-module-widget-from-another-module/7419/1 "2019-07-04T17:52:56Z")

</div>

I have 2 extensions, both built into a custom build of slicer. I have set it up so that ExtensionA (with ModuleABC) depends on ExtensionB (with Module XYZ). I would like to be able to get a handle on ExtensionBModuleXYZModuleWidget from ExtensionAModuleABCModuleWidget (for example to determine the value of a dropdown in the other widget). Is this possible to do in Slicer?

Thanks,  
Matt

---

<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:** [July 4, 2019, 6:11pm UTC](https://discourse.slicer.org/t/referencing-a-module-widget-from-another-module/7419/2 "2019-07-04T18:11:40Z")

</div>

A module should never ever access the widget of another module. Always communicate through MRML nodes.

If a module is implemented correctly then GUI changes are immediately reflected in changes in the associated parameter node. Other modules can observe changes in nodes and perform any actions as needed. See [PerkLab Slicer programming tutorials](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials) for more details and explanations.

---

<div class="post-metadata">

**Author:** ![MattTroke](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@MattTroke](https://discourse.slicer.org/u/MattTroke)\
**Post date:** [July 4, 2019, 6:17pm UTC](https://discourse.slicer.org/t/referencing-a-module-widget-from-another-module/7419/3 "2019-07-04T18:17:45Z")

</div>

Fair enough. My specific issue is with the Sequences extension. I want to know which is the active sequence browser selected in the Sequence Browser module. From what I can tell, there is no property of vtkMRMLSequenceBrowserNode that will communicate this.

---

<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:** [July 4, 2019, 7:43pm UTC](https://discourse.slicer.org/t/referencing-a-module-widget-from-another-module/7419/4 "2019-07-04T19:43:39Z")

</div>

You are not supposed to use the selection in the Sequence Browser module (selection can change when new sequence is loaded or the user modifies the selection for any reason, etc).

If you expect to have only a single sequence browser in the scene then you can get it from the MRML scene using [GetFirstNodeByClass()](https://apidocs.slicer.org/v4.8/classvtkMRMLScene.html#a21560f853d73548021e75d991d5aa34d).

If you have multiple sequence browser nodes then you can add a node selector widget in your module GUI. You can make the chosen sequence browser node selected in the toolbar using [`showSequenceBrowser` method](https://github.com/SlicerRt/Sequences/blob/master/SequenceBrowser/qSlicerSequenceBrowserModule.h#L79).

If you want to mirror browser node selection of the toolbar then you can retrieve the toolbar from the sequence browser module and add a connection to its [activeBrowserNodeChanged signal](https://github.com/SlicerRt/Sequences/blob/master/SequenceBrowser/Widgets/qMRMLSequenceBrowserToolBar.h#L60).

If all these still cannot satisfy your use case then we would need to learn a bit more about what would you like to do and how. We could add an accessor to the currently selected browser node in the toolbar or maybe save the currently selected browser node on the toolbar to the singleton Selection node.
