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:
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:
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,