I am a beginner at Slicer (1 week today), so I apologize if my question is simple. I am building a small module in which I would like to include the Segment Editor. In particular, I would like to set the maximum height of the ctkExpandableWidget object (i.e., the list of the segmentations) so as not to make it too long.
The following does what I want when executed in the Python console
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget() segmentEditorWidget.show() segmentEditorWidget.layout().itemAt(2).widget().setMaximumHeight(100)
However, when I put the same code in my .py file and insert it into my module, the ctkExpandableWidget object still behaves like the default ctkExpandableWidget (i.e., it can expand much further than this).
There is more code in my .py file (I followed a couple tutorials that also use the Segment Editor Widget in them), namely:
segmentationNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode') segmentationNode.CreateDefaultDisplayNodes() segmentEditorWidget.setMRMLScene(slicer.mrmlScene) segmentEditorNode = slicer.vtkMRMLSegmentEditorNode() slicer.mrmlScene.AddNode(segmentEditorNode) segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode) segmentEditorWidget.setSegmentationNode(segmentationNode) #inserts into a QGroupBox groupBoxSegmentation = qt.QGroupBox("Segmentation") segmentationLayout = qt.QVBoxLayout() segmentationLayout.addWidget(segmentEditorWidget) groupBoxSegmentation.setLayout(segmentationLayout)
Perhaps there is code in here that is overwriting the maximumHeight that I am trying to force?
Thank you for your help, and any comments to improve the above code are welcome!