How to add segment editor erase tool logic which is in C++ to a dummy python tool?

So I was able to create a copy of the smoothing tool in segment editor and name it as “x” (using info from:How can I create a copy of the segment editor erase effect and rename it?), but how can I add C++ functionality of erase into this tool in python? Any help is appreciated. Thanks.

All you need to do is to modify paintApply to call modifySelectedSegmentByLabelmap with the maskImage (similarlt as it is done in C++ in qSlicerSegmentEditorPaintEffect::paintApply).