# How to add additional buttons to scriptedsegmenteditoreffect?

**URL:** <https://discourse.slicer.org/t/how-to-add-additional-buttons-to-scriptedsegmenteditoreffect/34151>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [February 5, 2024, 11:25am UTC](https://discourse.slicer.org/t/how-to-add-additional-buttons-to-scriptedsegmenteditoreffect/34151 "2024-02-05T11:25:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tueboesen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tueboesen/32/69242_2.png) [@tueboesen](https://discourse.slicer.org/u/tueboesen)\
**Post date:** [February 5, 2024, 11:25am UTC](https://discourse.slicer.org/t/how-to-add-additional-buttons-to-scriptedsegmenteditoreffect/34151/1 "2024-02-05T11:25:08Z")

</div>

I am creating an extension for segment editor using the scriptedsegmenteditoreffect, and I would like to add another button to the widget.  
I saw how the on\_apply button is added in setupOptionFrame and tried to add another button in a similar fashion

```
def setupOptionsFrame(self):

    # Object scale slider
    self.objectScaleMmSlider = slicer.qMRMLSliderWidget()
    self.objectScaleMmSlider.setMRMLScene(slicer.mrmlScene)
    self.objectScaleMmSlider.quantity = "length" # get unit, precision, etc. from MRML unit node
    self.objectScaleMmSlider.minimum = 0
    self.objectScaleMmSlider.maximum = 10
    self.objectScaleMmSlider.value = 2.0
    self.objectScaleMmSlider.setToolTip("Increasing this value smooths the segmentation and reduces leaks. This is the sigma used for edge detection.")
    self.scriptedEffect.addLabeledOptionsWidget("Object scale:", self.objectScaleMmSlider)
    self.objectScaleMmSlider.connect("valueChanged(double)", self.updateMRMLFromGUI)

    # Apply button
    self.applyButton = qt.QPushButton("Accept")
    self.applyButton.objectName = self. __class__. __name__ + "Apply"
    self.applyButton.setToolTip("Accept previewed result")
    self.scriptedEffect.addOptionsWidget(self.applyButton)
    self.applyButton.connect("clicked()", self.onApply)

    # Do Nothing button
    self.dummyButton = qt.QPushButton("Dummy")
    self.dummyButton.objectName = self. __class__. __name__ + "Dummy"
    self.dummyButton.setToolTip("Dummy things")
    self.scriptedEffect.addOptionsWidget(self.dummyButton)
    self.dummyButton.connect("clicked()", self.onDummy)

```

This adds a new button in the widget, but unfortunately I am still missing something since the button does not activate the on\_dummy function as hoped. (See the image below)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/d/cd77cdcb4c2f4f526f7bc21a2992e0918bfb8777.png)

So how do I get more control over this button that I am adding, or is this not possible when using scriptedsegmenteditoreffect?  
If it is possible, then where I can find more information/documentation about this problem?

---

<div class="post-metadata">

**Author:** ![tueboesen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tueboesen/32/69242_2.png) [@tueboesen](https://discourse.slicer.org/u/tueboesen)\
**Post date:** [March 4, 2024, 9:36am UTC](https://discourse.slicer.org/t/how-to-add-additional-buttons-to-scriptedsegmenteditoreffect/34151/2 "2024-03-04T09:36:07Z")

</div>

I still haven’t figured out an answer to this question.  
I have tried reading up on the scriptedsegmenteditoreffect, but I can’t really find much in terms of documentation in [Developer Guide — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/index.html) and when searching for it on the github page I also do not really gain much in terms of code to look at.

I would appreciate if anyone could point me in the right direction

---

<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:** [March 4, 2024, 2:39pm UTC](https://discourse.slicer.org/t/how-to-add-additional-buttons-to-scriptedsegmenteditoreffect/34151/3 "2024-03-04T14:39:24Z")

</div>

So the button is there but the `clicked()` connection is not working? Maybe this isn’t it but your code says `onDummy` but in your message you say `on_dummy` which would not work. One thing we don’t typically do but should is check the return value of the call to `connect()`. It returns a boolean you can test to see if the connection worked.

---

<div class="post-metadata">

**Author:** ![tueboesen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tueboesen/32/69242_2.png) [@tueboesen](https://discourse.slicer.org/u/tueboesen)\
**Post date:** [March 4, 2024, 2:54pm UTC](https://discourse.slicer.org/t/how-to-add-additional-buttons-to-scriptedsegmenteditoreffect/34151/4 "2024-03-04T14:54:39Z")

</div>

This is embarrassing to admit, but that was indeed the problem… Thank you so much.  
And sorry for asking such a dumb question…
