Reload button loads dependent modules

It would be nice to have the feature in the title. My workaround is to modify the file

  bin/python/slicer/ScriptedLoadableModule.py                               

and add these lines in onReload(self) function

   myModules = ["myModules1","myModules2","myModules3"]
   if self.moduleName in myModules:
      print("Reloading myMainModule ............")
      slicer.util.reloadScriptedModule("myMainModule")

just before

     slicer.util.reloadScriptedModule(self.moduleName)

If your module requires reloading of additional modules or packages then you can override onReload method in your module.

Reloading multiple files is typically not very robust, because there can be cross-references between various modules and packages and so you may need to repeat reloading 2-3x until all references to old implementations are replaced. For good results, you may need to have hand-crafted code that reloads the right pieces in a particular order, maybe multiple times, maybe with some additional initialization steps. This cannot be easily automated and added to the base class.

1 Like