Shortcut for Sphere brush

I’m trying to set up a key shortcut in python to enable/disable sphere brush in PaintEffect. The first step is code to set that parameter, which I’m doing like this:

segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
paintEffect = segmentEditorWidget.effectByName("Paint")
paintEffect.setCommonParameter("BrushSphere", False)
paintEffect.updateGUIFromMRML()

The parameter does not seem to change the brush behavior and I don’t get any changes reflected in the GUI. What am I doing wrong here?

Thanks!!!

-Hollister

Instead of creating a new widget, refer to the Segment Editor module’s widget:

segmentEditorWidget = slicer.modules.segmenteditor.widgetRepresentation().self().editor
paintEffect = segmentEditorWidget.effectByName("Paint")
paintEffect.setCommonParameter("BrushSphere", 1)  # enable
paintEffect.setCommonParameter("BrushSphere", 0)  # disable

Oh, I see - I didn’t realize that I was creating a new widget (rather than finding the existing one).

THANKS!

-Hollister

1 Like