# Volumes widget is too wide when there are many decimals

**URL:** https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434
**Category:** Feature requests
**Created:** [November 10, 2017, 7:10pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434 "2017-11-10T19:10:13Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [November 10, 2017, 7:10pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/1 "2017-11-10T19:10:13Z")

</div>

Title and screenshot image say it all. The module widget takes more than 50% of my screen and I can’t resize it.

 ![45](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/6/f6d74a19aa4cbe28d5c8bb986551ff9ac190a492.png)

It says 4 decimals here:  
[https://github.com/Slicer/Slicer/blob/eefeac9286f48552e8418a11f412b2823a09b407/Libs/MRML/Widgets/Resources/UI/qMRMLVolumeInfoWidget.ui#L95-L98](https://github.com/Slicer/Slicer/blob/eefeac9286f48552e8418a11f412b2823a09b407/Libs/MRML/Widgets/Resources/UI/qMRMLVolumeInfoWidget.ui#L95-L98)

When I try to access the widget, I get 3:

```python
v = slicer.modules.volumes.widgetRepresentation()
>>> for cw in v.findChildren('qMRMLCoordinatesWidget'):
... print(cw.decimals)
... 
0
3
3

```

But in Slicer there are many more.

P.S.: I’m not sure if it’s the right category or if I should’ve posted directly in the issue tracker.

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [November 16, 2017, 12:02am UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/2 "2017-11-16T00:02:16Z")

</div>

Should I report this somewhere else? I can try to help with some guidance.

---

<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 16, 2017, 2:18am UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/3 "2017-11-16T02:18:56Z")

</div>

I cannot reproduce this. Can you give detailed instructions?

Does it help if you reduce the number of shown digits using `Ctrl`+`-` shortcut? Is it possible that you’ve accidentally hit `Ctrl`+`+` several times and that increased the number of shown digits?

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [November 16, 2017, 8:58am UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/4 "2017-11-16T08:58:09Z")

</div>

> [@lassoan](#):
>
> Can you give detailed instructions?

1. Open Slicer
2. Open [this volume](https://we.tl/5vKhQXgIbi)
3. Go to `Volumes` module
4. Click on `Volume Information`

> [@lassoan](#):
>
> Does it help if you reduce the number of shown digits using Ctrl± shortcut?

Nothing happens when I click `Ctrl + -` or `Cmd + -` (I’m on a MacBook Pro Retina 13").

> [@lassoan](#):
>
> Is it possible that you’ve accidentally hit Ctrl++ several times and that increased the number of shown digits?

No, and this is something that has happened to me as long as I can remember. Just hadn’t reported it yet.

> [@lassoan](#):
>
> I cannot reproduce this.

Maybe a macOS user can reproduce. @fedorov?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [November 16, 2017, 4:37pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/5 "2017-11-16T16:37:59Z")

</div>

@Fernando I cannot reproduce it either

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/8/68dc1b0cc8e9c518ee725a7b6ea84839010f2e0d.png)

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [November 16, 2017, 4:40pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/6 "2017-11-16T16:40:03Z")

</div>

I can also confirm that if I put the cursor into a field from Image Origin, I can then use `Command + +` / `Command + -` to increase/decrease the number of decimals.

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [November 16, 2017, 4:55pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/7 "2017-11-16T16:55:50Z")

</div>

> [@fedorov](#):
>
> @Fernando I cannot reproduce it either

That’s probably because MRHead has fewer decimals in its header than the image I shared.

> [@fedorov](#):
>
> if I put the cursor into a field from Image Origin

I didn’t know I was supposed to enable one of the widget’s spin boxes. I can decrease the number of decimals of one spin box now, but as soon as I do the same on another one, the former goes back to its initial length so the module widget’s width stays the same.

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [November 16, 2017, 5:11pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/8 "2017-11-16T17:11:51Z")

</div>

> [@Fernando](#):
>
> That’s probably because MRHead has fewer decimals in its header than the image I shared.

No, I checked that:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/a/fafbdfbdc8e55a7adcb14647d9a5ce68cc6189a5.png)

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [November 16, 2017, 5:12pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/9 "2017-11-16T17:12:46Z")

</div>

I don’t know if this detail matters, but for this experiment I was using a nightly build from August.

---

<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 16, 2017, 6:22pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/10 "2017-11-16T18:22:05Z")

</div>

@Fernando Have you adjusted units in your application (Edit/Application Settings/Units)? It may effect how length values are displayed.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [November 16, 2017, 9:33pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/11 "2017-11-16T21:33:22Z")

</div>

I was able to replicate the behavior reported by @Fernando using the volume he provided.

As a workaround I can change the behavior by changing the decimalsOption like this:

```auto
>>> for w in findChildren(className='qMRMLCoordinatesWidget'):
... w.decimalsOption = 0

```

I didn’t look deeper but there are a number of options and maybe we should pick a different default (or debug the version we are using which is 7 = DecimalsByShortcuts | DecimalsByKey | DecimalsByValue) for the ImageOrigin.

> <https://github.com/commontk/CTK/blob/cdb75ce742f618112b8a0f299a484d00baa4e8ff/Libs/Widgets/ctkDoubleSpinBox.h#L110-L152>

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [November 16, 2017, 10:47pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/12 "2017-11-16T22:47:16Z")

</div>

> [@pieper](#):
>
> using the volume he provided

Sorry, I missed that link! Interesting that the issue is specific to the dataset.

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [November 17, 2017, 10:14am UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/13 "2017-11-17T10:14:25Z")

</div>

> [@lassoan](#):
>
> Have you adjusted units in your application (Edit/Application Settings/Units)? It may effect how length values are displayed.

This didn’t have any effect.

> [@pieper](#):
>
> As a workaround I can change the behavior by changing the decimalsOption like this:
> 
> \>\>\> for w in findChildren(className=‘qMRMLCoordinatesWidget’):  
> … w.decimalsOption = 0

This made the `Image Spacing` widget use 4 decimals and 1 out of 3 spin boxes from `Image Origin` use 3.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [November 17, 2017, 3:47pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/14 "2017-11-17T15:47:32Z")

</div>

The snippet I pasted will change the modes for all the coordinate widgets. If there’s a good combination of ‘decimals’ and ‘decimalsOption’ that works well we could make that the new default. I didn’t try all the enum combinations for decimalsOptions.

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [April 8, 2018, 10:37pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/15 "2018-04-08T22:37:50Z")

</div>

Hi Steve,

I just tried again your snippet and it helped me reduce the size of the widget, but it still takes a lot of space (around 45% of the screen) and it feels like it should need much less, maybe 30%. Shall I work on a PR to change the defaults of the module?

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [April 8, 2018, 10:41pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/16 "2018-04-08T22:41:01Z")

</div>

By the way, when I collapse the `Volume Information` button, I can reduce a the size of the widget to a reasonable width.

---

<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: [April 8, 2018, 11:19pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/17 "2018-04-08T23:19:24Z")

</div>

It could be also possible to change the coordinate widget to use flow layout ([http://www.commontk.org/docs/html/classctkFlowLayout.html](http://www.commontk.org/docs/html/classctkFlowLayout.html)), which automatically places widgets into several rows if horizontal space is limited.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [April 9, 2018, 12:06pm UTC](https://discourse.slicer.org/t/volumes-widget-is-too-wide-when-there-are-many-decimals/1434/18 "2018-04-09T12:06:05Z")

</div>

> [@Fernando](#):
>
> Shall I work on a PR to change the defaults of the module?

Yes, if you find a new set of defaults or other change (like layout as @lassoan suggested) it would be great to have a PR to test.
