Using Markups module in custom Python module

Hello, I’m working on a custom Python scripted module that’ll deal with contours. Therefore, I want to be able to create markups with the custom module, and save these markups in certain directories after the user has finished drawing. Is there a way to use Markups in my own module?

I found this on the repository, which brings up a pop-up that allows you to create markups.

w=slicer.qSlicerMarkupsPlaceWidget()
w.setMRMLScene(slicer.mrmlScene)
markupsNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLMarkupsCurveNode”)
w.setCurrentNode(slicer.mrmlScene.GetNodeByID(markupsNode.GetID()))
w.buttonsVisible=False
w.placeButton().show()
w.show()

The issue is that when I use this in my Python file, the pop-up shows up and then immediately closes. Is there a condition I can use to keep the pop-up open until the user closes it?

I don’t know what OS you are using but the behavior in linux is that popup will still exist but is behind the Slicer window after placing the Markup.

I’m on Windows. I can’t find the popup anywhere, not even behind the Slicer window. What seems to happen is that the popup briefly appears before disappearing. However, the markup is still made and accessible in the subject hierarchy, though it has no control points.

I tested the script repository code on a fresh install of Slicer stable on Win 10 and the results were the same as linux, the popup persists but moves behind the Slicer window. The code itself works so there must be something else about your system causing it to fail.