# Layout change doesn't work

**URL:** <https://discourse.slicer.org/t/layout-change-doesnt-work/14451>\
**Category:** Support\
**Created:** [November 5, 2020, 8:25pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451 "2020-11-05T20:25:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 5, 2020, 8:25pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/1 "2020-11-05T20:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2020, 8:56pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/2 "2020-11-05T20:56:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 5, 2020, 9:54pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/3 "2020-11-05T21:54:27Z")

</div>

Okey Andras. Here is the [link](https://github.com/mauigna06/PedicleScrewSimulator/blob/b79fdc94e9c2337db5420c9f97774150c17eeb82/PedicleScrewSimulator/PedicleScrewSimulatorWizard/ScrewStep.py#L282). Thanks for the help

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 5, 2020, 10:46pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/4 "2020-11-05T22:46:35Z")

</div>

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](https://www.slicer.org/wiki/Documentation/Nightly/Extensions/DebuggingTools#Debugging_in_VisualStudio_Code)

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 5, 2020, 11:23pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/5 "2020-11-05T23:23:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 6, 2020, 7:32pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/6 "2020-11-06T19:32:43Z")

</div>

I was able to set it up. I would suggest you include the contents of [this](https://discourse.slicer.org/t/developing-slicer-modules-in-visual-studio-visual-studio-code/9496/19) post in the tutorial of above because I had to edit settings.json file to make it work. Thank you for the help

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 6, 2020, 8:12pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/7 "2020-11-06T20:12:25Z")

</div>

Setting up those additional paths takes a little effort and does not do much (see [here](https://discourse.slicer.org/t/developing-slicer-modules-in-visual-studio-visual-studio-code/9496/23)), 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.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 6, 2020, 9:25pm UTC](https://discourse.slicer.org/t/layout-change-doesnt-work/14451/8 "2020-11-06T21:25:51Z")

</div>

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.
