Link slice views outside of

I’m writing an extension and I would like that it automatically links the slice views. I know I can add it to, and this works, however, I wouldn’t want to ‘ship’ a custom together with my extension.

I tried to take the code from Set all slice views linked by default, put it in a function linkViews() in my and add it to the the __init__() of class MyExtension(ScriptedLoadableModule) similarily to the sample data:"startupCompleted()", linkViews)

However, this doesn’t work - it doesn’t throw any error - the code gets executed (if I add a print() it prints to the console) but the views remain unlinked.

Can this be done as part of an extension?

This is probably a timing issue - the startupCompleted signal comes after the windows already exist, while the is processed during command line processing where the windows must not have been set up yet.

Can you try calling linkViews directly in the __init__()?

1 Like

Calling linkViews directly in the __init__() of MyExtension(ScriptedLoadableModule) doesn’t work.

However, it works when I call it in the __init__() of MyExtensionWidget(ScriptedLoadableModuleWidget, VTKObservationMixin) or MyExtensionLogic(ScriptedLoadableModuleLogic)