I am generating scenes containing patient imaging/segmentation data, saving as MRB, and sending to our clinical team. They often have several Slicer instances opened with different MRB files loaded.
Is it possible to set each Slicer instance Main Window title to the name of the opened MRB file?
You can use slicer.mrmlScene.GetURL() to add the mrb file name to the window title.
However, since scene files are always imported (current scene content is not replaced) the mrb file name is not always an accurate description of the scene content. It might be safer to rely on what is shown in Data module or in corner annotations:
@rbumm thank you for the code snippet. I combined this with Andras’s suggestion in the .slicerrc.py file. The outcome is exactly what I was looking for.
Thanks for sharing your solution. Updating the window title is a very lightweight operation, so it should not matter that you do it whenever a node is added to the scene. If you just want to do something when a scene is loaded (e.g., because it is a more lengthy operation) then instead of slicer.vtkMRMLScene.NodeAddedEvent you can observe the slicer.vtkMRMLScene.EndImportEvent event instead.
For completeness, how should I handle the scene close event. Currently, the Main Window title remains when the scene is closed. I would like the title to return back to default when the scene is closed. I initially was going to use slicer.vtkMRMLScene.NodeRemovedEvent but sense this is not the best option