# Permanently hide MaskingGroupBox

**URL:** <https://discourse.slicer.org/t/permanently-hide-maskinggroupbox/7959>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [August 9, 2019, 11:14am UTC](https://discourse.slicer.org/t/permanently-hide-maskinggroupbox/7959 "2019-08-09T11:14:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricM](https://avatars.discourse-cdn.com/v4/letter/e/48db29/32.png) [@EricM](https://discourse.slicer.org/u/EricM)\
**Post date:** [August 9, 2019, 11:14am UTC](https://discourse.slicer.org/t/permanently-hide-maskinggroupbox/7959/1 "2019-08-09T11:14:20Z")

</div>

Hello community,

I am trying to simplify the segmentEditorWidget as much as possible. One feature I would like to do is hide the “MaskingGroupBox” in the “Paint” and “Draw” Effects. I have automatically set the “Modify other segments” to “Allow overlap”, and now, I would like to hide the entire MaskingGroupBox to avoid the user changing this.

I have tried the following:

```auto
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
#various commands to set MRML scene, adding nodes, etc.
maskingGroupBox = segmentEditorWidget.findChild('ctkCollapsibleGroupBox','MaskingGroupBox')
maskingGroupBox.findChild('QComboBox','OverwriteModeComboBox').setCurrentIndex(2)
maskingGroupBox.setHidden(True)

```

However, every time I click on the “Paint” or “Draw” QToolButton, the MaskingGroupBox always reappears. I have noticed that when clicking on these buttons, the following signals are produced: Pressed, Toggled, Clicked.

I thus tried:

```auto
effectsGroupBox = segmentEditorWidget.findChild('QGroupBox','EffectsGroupBox')
paintButton = effectsGroupBox.findChild('QToolButton','Paint')
drawButton = effectsGroupBox.findChild('QToolButton','Draw')

def hideMaskingGroupBox():
  slicer.util.mainWindow().findChild('qSlicerModulePanel','ModulePanel').findChild('ctkCollapsibleGroupBox','MySegmentation').findChild('ctkCollapsibleGroupBox','MaskingGroupBox').hide() #this is where I keep my segmentEditorWidget module

paintButton.pressed.connect(hideMaskingGroupBox)
paintButton.toggled.connect(hideMaskingGroupBox)
paintButton.clicked.connect(hideMaskingGroupBox)

drawButton.pressed.connect(hideMaskingGroupBox)
drawButton.toggled.connect(hideMaskingGroupBox)
drawButton.clicked.connect(hideMaskingGroupBox)

```

For a brief moment, I can see the MaskingGroupBox disappear, but then it always reappears, so there must be another action after the last “clicked” signal that makes the MaskingGroupBox reappear. What makes me think this is because If I click again on the already clicked “Paint” or “Draw” box, the MaskingGroupBox disappears. However, if I switch Effects, it appears again…

Is there anyway to override this? Could someone let me know what action is causing the MaskingGroupBox to appear automatically?

Thank you for your help,  
Eric

---

<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:** [August 10, 2019, 6:39pm UTC](https://discourse.slicer.org/t/permanently-hide-maskinggroupbox/7959/2 "2019-08-10T18:39:36Z")

</div>

It would be hard to hack the segment editor widget from outside to prevent the masking section to reappear. Instead, you could add a “maskingOptionsVisible” property to [qMRMLSegmentEditorWidget](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/Widgets/qMRMLSegmentEditorWidget.cxx) that would prevent the groupbox to be displayed [here](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/Widgets/qMRMLSegmentEditorWidget.cxx#L1638).

This would be a small change, so if you send us a pull request then we should be able to review and integrate it very quickly.

---

<div class="post-metadata">

**Author:** ![EricM](https://avatars.discourse-cdn.com/v4/letter/e/48db29/32.png) [@EricM](https://discourse.slicer.org/u/EricM)\
**Post date:** [August 13, 2019, 8:27am UTC](https://discourse.slicer.org/t/permanently-hide-maskinggroupbox/7959/3 "2019-08-13T08:27:24Z")

</div>

Hi Andras,  
Thanks for your quick reply. I will build Slicer and try to modify the source code. I will probably get around to trying this in the beginning of September. I’ll keep everyone posted.  
Thanks,  
Eric
