How to enable apply button in new created Extension Wizard module?


I am new in Slicer programming.

Created a module using extension wizard, however, the self.applyButton in Widget class is always disabled. I use PyCharm to debug, and in the function

def onSelect(self):
        self.applyButton.enabled = self.inputSelector.currentNode() and self.outputSelector.currentNode()

when a new volume is loaded, the function onSelect is triggered, both inputSelector and outputSelector are not null. However, I could never see the applyButton enabled.

Why couldn’t the applyButton be enabled?
How should I enable it? Or should I change the code?

Thank you very much!

I would recommend to use the latest “scripteddesigner” module template. GUI state updates should be more clear now. If you have any questions about this latest template then let us know.

If you want to keep using the old template then adding a breakpoint in PyCharm execute the code step-by-step is a good way to understand what your code does (and why it is not the same what you expect).

Hi Iassoan,

The latest template you recommended using UI framework seems even harder to understand. Any resource as a tutorial showing how to build a customerized template?

I am more familiar with qt commands without using UI, do you have any tutorial explanation for the template without UI, please?

Thank you very much!

Maybe you have checked an earlier version? ScriptedDesigner template was already quite well documented, but I added even more comments. If anything is still unclear then let me know.

We have found that using a .ui file for creating GUI makes the GUI easier to design and the code easier to debug and maintain. If you are not familiar with it then check out this tutorial.

1 Like

Hi Iassoan,

In the extension wizard template, the run function in Logic class was commented as “run the actual algorithm”, but there is not much explanation about how the thresholded output volume was calculated:

# Compute the thresholded output volume using the Threshold Scalar Volume CLI module
cliParams = {'InputVolume': inputVolume.GetID(), 'OutputVolume': outputVolume.GetID(), 'ThresholdValue' : imageThreshold, 'ThresholdType' : 'Above'}
cliNode =, None, cliParams, wait_for_completion=True)

where I was not able to extract any useful information from function…) :sweat_smile:

Could you please explain a little about how slicer.modules.thresholdscalarvolume applied the algorithm? And what exactly is the algorithm?

Thank you very much!

The example shows how to run a CLI module from Python. See more information about CLI modules in general in the Slicer developer tutorials, and more details about how to run them and how to get their input/output parameters are available here. Source code of CLI modules bundled with Slicer are available here.

You can run any other processing using VTK, SimpleITK, numpy, various Slicer modules provided by extensions, and any Python packages. See a variety of examples in the script repository.

Hi Iassoan,

Thank you for providing the link to the code of thresholdscalarvolume module!

Is the link below where I should investigate for the algorithm of ThresholdScalarVolume?
It seems that the module does not contain any comments, and I was not able to find out how the threshold was applied. :sweat_smile:

Would you be able to let me know how to locate the function that actually applied the algorithm of ThresholdScalarVolume, please?

Most CLI modules use ITK filters to process data. You can find documentation, examples, and source code by searching for the filter name on the web (e.g., itk::ThresholdImageFilter).
You can run ITK filters directly in Python using SimpleITK, which is bundled with Slicer. You can also implement trivial operations, such as image thresholding using numpy. These are all described in the PerkLab Slicer programming tutorial that I linked above.

Hi Andras,
Why this scripteddesigner not available in new slicer versions. when I create an extension it shows me


it does give me a scripted designer in the list.

Thank you

The old “scripted” template was removed and “scripteddesigner” template was renamed to “scripted”.

1 Like