# Create a new window with multiple slice views

**URL:** <https://discourse.slicer.org/t/create-a-new-window-with-multiple-slice-views/28132>\
**Category:** Support\
**Created:** [March 2, 2023, 12:12am UTC](https://discourse.slicer.org/t/create-a-new-window-with-multiple-slice-views/28132 "2023-03-02T00:12:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhodesdante](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@rhodesdante](https://discourse.slicer.org/u/rhodesdante)\
**Post date:** [March 2, 2023, 12:12am UTC](https://discourse.slicer.org/t/create-a-new-window-with-multiple-slice-views/28132/1 "2023-03-02T00:12:20Z")

</div>

Is it possible to create a new window with multiple slice views? [This example](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-a-slice-view-outside-the-view-layout) shows how to create a single additional view, but I am attempting to create multiple additional views so I can display them on a separate monitor. I am assuming this requires some sort of creation of layoutNodes and the like, as is done in the [qSlicerMainWindow](https://github.com/Slicer/Slicer/blob/fca9db1aa635e5bcf2d61b62ac6beccce844cf86/Base/QTApp/qSlicerMainWindow.cxx). Is this correct, or is there a simpler way to acheive this functionality?  
Thanks!

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [March 2, 2023, 12:28am UTC](https://discourse.slicer.org/t/create-a-new-window-with-multiple-slice-views/28132/2 "2023-03-02T00:28:00Z")

</div>

You’ll actually be interested in the concept of multiple viewports for a given layout which is specifically for the use case of multiple monitors. This is available using latest Slicer 5.3 Preview builds.

[https://slicer.readthedocs.io/en/latest/developer\_guide/advanced\_topics.html#example-layout-containing-two-viewports](https://slicer.readthedocs.io/en/latest/developer_guide/advanced_topics.html#example-layout-containing-two-viewports)

The associated PR that added this functionality:

> <https://github.com/Slicer/Slicer/pull/6776>
>
> Layouts can now contain multiple viewports. The default viewport is displayed as… the center widget of the application main window, additional Additional viewports can be independent top-level windows or docking windows.
> 
> Views can be maximized/restored separately in each viewport.
> 
> Currently, a single new dual-viewport layout is added: Dual Monitor Four-Up View
> 
> !\[image\](https://user-images.githubusercontent.com/307929/211677816-0a77cd67-f564-46b3-87d0-944f19da22c8.png)
> 
> Associated CTK pull request (already merged): https://github.com/commontk/CTK/pull/1061 first.

---

<div class="post-metadata">

**Author:** ![rhodesdante](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@rhodesdante](https://discourse.slicer.org/u/rhodesdante)\
**Post date:** [March 3, 2023, 5:54pm UTC](https://discourse.slicer.org/t/create-a-new-window-with-multiple-slice-views/28132/3 "2023-03-03T17:54:38Z")

</div>

Thanks so much @jamesobutler! This solution worked very well for me. Using the developer guide example you showed and the snippet below (modified from the compare volumes module), I was able to customize the layout of the second monitor view to fit my needs.

```
#customLayout is the user's custom XML string specifying the layout, as in the example above
# Built-in layout IDs are all below 100, so you can choose any large random number for your custom layout ID.
customLayoutId = 501
layoutManager = slicer.app.layoutManager()
layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)
# Switch to the new custom layout
layoutManager.setLayout(customLayoutId)

```
