Additional code with functions

Hello,

I want to submit my extension to the Extension Manager this week.


As you can see in the attached image, each module folder has the main .py file that has same name as the module, but also several other .py files that the main module file imports so that it can call the functions in those other .py files.

Is this ok, or does each module folder have to have only the one .py file with same name as the module? If it’s ok to have multiple .py files in the module folder, how do I make sure that an error like this:

RuntimeError: qSlicerScriptedLoadableModule::setPythonSource - Failed to load scripted loadable module: class chooseEarly_LateByManufacturer was not found in file C:/Users/rnadkarni/SlcExt/Breast_DCEMRI_FTV/DCE_IDandPhaseSelect/chooseEarly_LateByManufacturer.py

doesn’t prevent the user from being able to use my extension?
On the main Windows computer I’m developing this extension on, I am able to ignore this error message and run the modules without issue. But I tried on my Mac laptop and this error appears to be the reason that module 1 of my extension is unavailable to use.

Thanks,
Rohan

You can place those other python files in a Lib folder that you import into your module. Slicer looks at all .py files in the module path and tries to load them but won’t look inside subfolders. There are lots of examples of this, but here’s a good one:

1 Like