Python script crashes when running w/o GUI due to smoothing effect

I try to run a python script via the command ./Slicer --no-splash --no-main-window --python-script ‘customScript.py’.

It crashes when executing the following line: segmentEditorWidget.setActiveEffectByName("Smoothing"), however, it works when I remove the flag --no-main-window and also when the same code is run via a Jupyter Notebook.

Is there any way to apply smoothing effect w/o a GUI?

Slicer version: 5.2.2

Thanks!

Presence of a main window is required for most application features. Having a main window is generally useful - it allows quick direc visualization, often used side-by-side with the notebook - but if you don’t want to see it then you can minimize the main window right after the application has started.

If you really don’t want a window to pop up you could also run Slicer in a docker, although that’s a lot of installation overhead compared to just minimizing the window.

Ok, then I know. Thanks!