# Best practice for accessing ScriptedLoadableModuleLogic from Module?

**URL:** <https://discourse.slicer.org/t/best-practice-for-accessing-scriptedloadablemodulelogic-from-module/27899>\
**Category:** Support\
**Tags:** python\
**Created:** [February 18, 2023, 4:55am UTC](https://discourse.slicer.org/t/best-practice-for-accessing-scriptedloadablemodulelogic-from-module/27899 "2023-02-18T04:55:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 18, 2023, 2:49pm UTC](https://discourse.slicer.org/t/best-practice-for-accessing-scriptedloadablemodulelogic-from-module/27899/2 "2023-02-18T14:49:38Z")

</div>

For a scripted loadable module, the module class will automatically create the widget based on the class name (MyModule, MyModuleWidget). You don’t need to add any code to the base Module class for this.

As mentioned on one of the slides “Current limitation: Scripted module logic is not created automatically, it has to be instantiated in the Widget class.” So as seen in the template the logic is instantiated in the widget class. (`self.logic = MyModuleLogic()`)

If there are issues during startup loading order, they can usually be mitigated by utilizing the startupCompleted signal. See linked thread:

> [@Import order in a scripted loadable module](https://discourse.slicer.org/t/import-order-in-a-scripted-loadable-module/21814/4):
>
> When a module class is instantiated, it is still the module discovery phase (the application scans what modules are available, builds a dependency tree, determines in which order the modules will be initialized). Slicer application or other modules are not available yet. If you want to do something at application startup then you can connect a method to the application’s startupCompleted() signal: Create logic object on startupCompleted() signal and store it in the module class. This is only n…

---

_[View the full topic](https://discourse.slicer.org/t/best-practice-for-accessing-scriptedloadablemodulelogic-from-module/27899)._
