Layout change doesn't work

I add this line slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView) on the end of the createUserInterface function on the ScrewStep.py module of the Pedicle Screw Simulator Extension and it doesn’t work. It keeps showing the ‘3D only’ view.
But if I write that line on the python console, it works. Why this happens? I have checked with debug flags (before that line and after that line) and the code does run

Please push your change to your fork and send a link to the line where you set the layout.

Okey Andras. Here is the link. Thanks for the help

Thanks for the link. It makes it clear what the issue is. It is way too early to set the layout there, as the layout is set at each workflow step (search for setLayout in the code).

A debugger would help you tremendously - you can put a breakpoint, inspect variables, run any code at any time. See setup instructions here: https://www.slicer.org/wiki/Documentation/Nightly/Extensions/DebuggingTools#Debugging_in_VisualStudio_Code

Thank you Andras. I’ll install Visual Studio Code and Slicer’s Python debugger module.

1 Like

I was able to set it up. I would suggest you include the contents of this post in the tutorial of above because I had to edit settings.json file to make it work. Thank you for the help

Setting up those additional paths takes a little effort and does not do much (see here), so overall I would not recommend users to spend time with specifying these additional settings. If you can make VTK, MRML, CTK, or Qt method name (not just class name) auto-complete or documentation work then let me know - then it may worth the trouble of setting up more paths.

You are right Andras. I think I just needed to set up the python.pythonPath variable to Slicer’s python to make it work and everything else on the settings.json file is not needed.