# How to programmatically add create new segmentation as button?

**URL:** <https://discourse.slicer.org/t/how-to-programmatically-add-create-new-segmentation-as-button/17449>\
**Category:** Development\
**Tags:** python\
**Created:** [May 4, 2021, 4:41pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-create-new-segmentation-as-button/17449 "2021-05-04T16:41:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [May 4, 2021, 4:41pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-create-new-segmentation-as-button/17449/1 "2021-05-04T16:41:44Z")

</div>

I know that in segment editor the user has the ability to create a new segmentation and name the new segment using "create new segment as … ". Is there any way I can perform that programmatically? I just want to give the user the option to input the new name of the segmentation after they click a button used for adding or subtracting segments in that subtraction. I use .setname to change the name but what would I use to give the user the option to set the name?

---

<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:** [May 21, 2021, 6:35pm UTC](https://discourse.slicer.org/t/how-to-programmatically-add-create-new-segmentation-as-button/17449/2 "2021-05-21T18:35:29Z")

</div>

You can enable `renameEnabled` flag for your MRML node selector widget to offer the user to create a new node with a specified name. You can set the default name in `baseName` property of the node selector.
