How reload module button works?

Hi,
Is the “Reload” button supposed to work in a ScriptedLoadableModuleTemplate right after creating it in the Extension Wizard? Or does something have to be set in the code?

I created a couple ScriptedLoadableTemplateModule with the Extension Wizard and then made some small changes to ScriptedLoadableModuleTemplate.py: self.parent.contributors and self.parent.acknowledgementText and pressed “Reload” but the changes don’t show up until I press “Restart Slicer” button and restart Slicer.

The “Enable Developer Mode” is checked.
It’s Slicer 4.6.2 on Mac OS X, binary version. I’m only tying to add in Python Modules.
I added the new ScriptedLoadableModuleTemplate directory (which are outside the Slicer installation directory) to the “Additional module paths:” and the added modules show up with the current changes when Slicer starts.

Best regards,
Karl

Use the latest nightly version, it should work correctly there. If you have trouble with latest nightly version, too, then let us know.

1 Like

Would it make sense to have the Python (script) CMake install step create a symlink from the runtime directory to the original script source in the source directory, on platforms where user symlink is supported? This would avoid the rebuild (make/ninja/etc.) step required to copy modified scripts from source tree to runtime directory before they can be reloaded…

I guess this could be as simple as changing the copy command to create_symlink in ctkMacroCompilePythonScript. But I think that will break packaging unless the copy step is done somewhere else, or if CPack can be told to follow symlinks. cc @jcfr @pieper

During development, I just add the source folder (not the install folder) to “Additional module paths” for scripted modules.

Hi Karl - changing the template after generating the module shouldn’t have any effect but changes to the generated scripted module should take effect after hitting the Reload button.

Like @lassoan during development I use Reload all the time. I don’t put the code in the Slicer tree and I typically don’t rebuild scripted modules during development. I run Slicer with the --additional-module-paths option followed by the list of module directories I want to test (since I often have several going at once and don’t want to change my settings).

@ihnorton I prefer to avoid things like symlinks that are not consistent across platforms.

Alright. Win10 Fall Creators Update does (finally) provide unprivileged symlinks, but it will take a while before that can be generally relied upon.