# Left and Right Panel Ratio

**URL:** <https://discourse.slicer.org/t/left-and-right-panel-ratio/18377>\
**Category:** Development\
**Created:** [June 28, 2021, 5:33pm UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377 "2021-06-28T17:33:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![OpenSource\_Contri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/opensource_contri/32/11189_2.png) [@OpenSource\_Contri](https://discourse.slicer.org/u/OpenSource_Contri)\
**Post date:** [June 28, 2021, 5:33pm UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377/1 "2021-06-28T17:33:15Z")

</div>

I want to know how the ratio of left panel and right panel work in slicer, which can be adjust by us. Which Slicer code-base file I have to explore to learn “how this actually work with the help of particular program”?

Three screenshot is attached.

 ![Screenshot (275)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/4/64f052e23f9431e3e0f2e2d0710998cfe81352ae.png)  
 ![Screenshot (276)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/8/48a0478610a54300d488047f58ebb77ed01e6150.png)  
 ![Screenshot (277)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/8/28d83866b11500846a29f7a14c3bbe6ef356a221.png)

---

<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:** [June 28, 2021, 10:39pm UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377/2 "2021-06-28T22:39:00Z")

</div>

It is all standard Qt behavior. Slicer does not impose any extra constraints, but Qt computes the allowed sizes for each section of the GUI (based on sizing policies set in each widget).

---

<div class="post-metadata">

**Author:** ![OpenSource\_Contri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/opensource_contri/32/11189_2.png) [@OpenSource\_Contri](https://discourse.slicer.org/u/OpenSource_Contri)\
**Post date:** [June 29, 2021, 10:23am UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377/3 "2021-06-29T10:23:01Z")

</div>

Sure, I will explore Qt.  
But I want to know which UI file I’ve to work on to learn this behavior for sliding left and right panel.

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [June 29, 2021, 2:11pm UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377/4 "2021-06-29T14:11:21Z")

</div>

Often, hiding the Data Probe (lower left widget in Slicer main window) solves the problem of randomly resizing module panels, which is an extremely annoying feature of Slicer UI.

If the problem still persists, you could insert this code on the python interactor to force a fixed with on the module panel and its contents. Or add this code to your module setup function so it is automatically applied every time you open your module (if you are working on a custom module):

> modulePanelDockWidget = slicer.util.mainWindow().findChildren(‘QDockWidget’,‘PanelDockWidget’)[0]  
> modulePanelDockWidget.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding)  
> modulePanelDockWidget.setFixedWidth(600)  
> modulePanelScrollArea = modulePanelDockWidget.findChild(“QWidget”, “dockWidgetContents”)  
> modulePanelScrollArea.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding)  
> modulePanelScrollArea.setFixedWidth(600)

---

<div class="post-metadata">

**Author:** ![OpenSource\_Contri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/opensource_contri/32/11189_2.png) [@OpenSource\_Contri](https://discourse.slicer.org/u/OpenSource_Contri)\
**Post date:** [June 30, 2021, 9:50am UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377/7 "2021-06-30T09:50:56Z")

</div>

Thanks, I have done that before.  
But I want to know how this left and right panel in screenshot above works. Which GUI file I have to explore?  
For example: If I say, I want to fix that left and right panel in the ratio of 25:75 then how to do it.

---

<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:** [July 2, 2021, 6:28pm UTC](https://discourse.slicer.org/t/left-and-right-panel-ratio/18377/8 "2021-07-02T18:28:51Z")

</div>

Since Qt dynamically changes the layout based on sizing policies of every visible widget. If you want to know what sizes the left panel may end up in various scenarios, you would need to review size policies of all the widgets of all the modules that you may use. This is of course practically infeasible.

Therefore, if you need to force a certain width for the left panel then probably your only option is to force a specific size as @ungi described above. You can query the screen size to compute how many voxels 25% of the screen width corresponds to.
