How to programmatically add create new segmentation as button?

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?

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.