# Reload button loads dependent modules

**URL:** <https://discourse.slicer.org/t/reload-button-loads-dependent-modules/7135>\
**Category:** Feature requests\
**Created:** [June 12, 2019, 10:31am UTC](https://discourse.slicer.org/t/reload-button-loads-dependent-modules/7135 "2019-06-12T10:31:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [June 12, 2019, 10:31am UTC](https://discourse.slicer.org/t/reload-button-loads-dependent-modules/7135/1 "2019-06-12T10:31:48Z")

</div>

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)
```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 12, 2019, 1:56pm UTC](https://discourse.slicer.org/t/reload-button-loads-dependent-modules/7135/2 "2019-06-12T13:56:57Z")

</div>

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.
