Access visible widgets

I know how to grab an active node like this

segmentEditorNode = slicer.mrmlScene.GetSingletonNode("SegmentEditor", "vtkMRMLSegmentEditorNode")

Is it possible to access the actual widgets without instantiating a new one? e.g.
instead of segmentEditorWidget = slicer.qMRMLSegmentEditorWidget() do something like the above. I think the answer is no based on this thread.

But I am curious to know what is the suggested approach? or maybe point me to the mental model of how the gui widgets interact with the mrmlScene?

You can access any Qt widgets and manipulate their properties. However, directly manipulating a widget that is managed by another module may cause errors (as you may change the state of the widget in a way that the owner module does not expect).

It is safe to modify MRML nodes and safe to modify state of widgets that you create, so these approaches are recommended. For testing purposes or some workflow automation (e.g., if you only simulate a few button clicks in a very controlled scenario, …) it might be acceptable to deviate from these.

What would you like to achieve? Is there something that you cannot do by sticking to the recommended approaches?

Thank you Andras,
I think my main confusion is wrapping my head around which things are used in what way depending on what it is. I think the workflow suggested is fine, but confusing still. what constitutes direct manipulation vs manipulations of properties? I think the model is that slicer.qMRMLSegmentEditorWidget() is some sort of instantiation of a gui itself and has the method setMasterVolumeNode, but the segmentEditorNode as created above thing is somehow linked to the gui and has a method SetAndObserveMasterVolumeNode.

they seem similar, but in order to activate and edit the segmentation pragmatically i need to use the widget, but when I am manually using the built in gui I am manipulating the same segmentation but with a different gui. maybe it’s the knowing what’s data vs the thing acting on the data?

:man_shrugging:

If you create a widget in your own module then you are free to do anything with it. However, you are not supposed to access GUI of another module.

You can either use a module from another module by modifying MRML nodes (they are shared between all modules and anybody can modify a MRML node anytime) or calling methods of the module logic class.

You may find our lab’s yearly bootcamp training materials useful, especially day3_2_SlicerProgramming.pptx, which explains some high-level design concepts.