Segment Editor doesn't work on custom slice

I added a custom slice outside the view layout using this script and tried to use segment editor paint on it. But it doesn’t work

How can I get the Segment Editor work on slice that outside the view layout?

Segment Editor gets the list of views from the layout manager, so all the views must be described in the view layout. The good news is that in recent Slicer versions, the layout manager can display views outside the main viewport in a dockable widget that you can make float over other views, displayed in a second monitor, placed right below your module panel, etc.