Iterate over slicer modules


I am working on creating a program to get all the modules loaded in Slicer. I know I can access the list with all the module names, I also know that I can access a module by hard typing the module name like “slicer.modules.modelmaker”. But is there a way to access a module with a variable or a string?

The first command I tried was slicer.modules[variable] but it can’t work because modules is a namespace.



Hum, sometimes when you don’t find what you want, it’s nice to get back to python basics.

Thanks a lot.

1 Like


You could also use the slicer util method getModule().



Based on the work done before, I was able to access the module, then the widget and the currentCLInode. So, I can get the parameters names, flags, types. But, I can’t find the way to access the current value corresponding to a parameter.
I saw there is a function ‘WriteParameterFile’ which is able to access the value and match it with the key but the source code can’t help me.

Hey Clement,

Did you look at GetParameterAsString() ?


Thank you so much Johan!

A post was split to a new topic: Access color table in CLI module