Referencing a module widget from another module

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?


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 for more details and explanations.

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.

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().

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.

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.

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.