# Running a custom extension on start

**URL:** https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256
**Category:** Development
**Created:** [March 2, 2022, 9:50am UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256 "2022-03-02T09:50:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Vincebisca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vincebisca/32/10722_2.png) [@Vincebisca](https://discourse.slicer.org/u/Vincebisca)
#### Post date: [March 2, 2022, 9:50am UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256/1 "2022-03-02T09:50:21Z")

</div>

Hello,

I am searching for a way to start a custom extension directly when starting 3D Slicer (some kind of modified .exe file, I don’t know).  
I am very bad at coding but managed somehow a few months ago to create a custom extension for a personal project using the QuickSegment template that I found. I would like to have a shortcut that starts 3D Slicer directly on this extension.

I have tried the command method first, described at [Documentation/Nightly/Developers/Slicelets - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets) but didn’t work. I don’t understand why it works on ordinary modules like Transforms or Colors, but not on Extensions such as SlicerElastix. And it doesn’t work for my own extension…

Would really appreciate if someone can help me out !

Thank you !

---

<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: [March 2, 2022, 12:07pm UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256/2 "2022-03-02T12:07:32Z")

</div>

Does setting your module as the “Home” module work for your purposes? For options on how to implement this, see [Open a slicer module with python](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754).

---

<div class="post-metadata">

### Author: ![Vincebisca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vincebisca/32/10722_2.png) [@Vincebisca](https://discourse.slicer.org/u/Vincebisca)
#### Post date: [March 2, 2022, 12:26pm UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256/3 "2022-03-02T12:26:04Z")

</div>

That is a good suggestion, and it might work, but it would make my 3D Slicer always start on this module, and it’s an internal setting… What I am trying to do is really to have an external shortcut that opens 3D Slicer on my Extension. That way I (and other people I work with) can access this feature when they need to, without internal configuration. Don’t know if I’m clear enough tho… Not a pro at all

---

<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: [March 2, 2022, 12:28pm UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256/4 "2022-03-02T12:28:58Z")

</div>

You can create a shortcut that includes the flag as suggested in the following post as that doesn’t require going into Slicer first and setting the “Home” module setting.

> [@Open a slicer module with python](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754/2):
>
> As an example I add this to the command line when I start slicer: --python-code "selectModule('WebServer')" But you can put the same in .slicerrc.py, maybe using slicer.util.selectModule for style purposes.

---

<div class="post-metadata">

### Author: ![Vincebisca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vincebisca/32/10722_2.png) [@Vincebisca](https://discourse.slicer.org/u/Vincebisca)
#### Post date: [March 2, 2022, 12:32pm UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256/5 "2022-03-02T12:32:08Z")

</div>

I tried something similar, but even with the command console, I can’t zuse the --python-code “selectModule(‘MyModule’)” command on my module, it doesn’t work also for SlicerElastix. I don’t know if it’s because they have a different status than internal modules such as Transforms…

Edit: doesn’t work with SegmentEditorExtraEffects, but works with MarkupsToModel. The main difference I see is that MarkupsToModel seems to be a loadable module, as opposed to the others which are scripted modules, but I don’t really know the difference

---

<div class="post-metadata">

### Author: ![Vincebisca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vincebisca/32/10722_2.png) [@Vincebisca](https://discourse.slicer.org/u/Vincebisca)
#### Post date: [March 2, 2022, 1:07pm UTC](https://discourse.slicer.org/t/running-a-custom-extension-on-start/22256/6 "2022-03-02T13:07:52Z")

</div>

Okay found it, the problem was that for an unknown reason, my module is still recognized as “QuickSegment”, the template’s name, and not by the name I gave. So it worked to modify the shortcut properties with the command line --python-code “slicer.util.selectModule(‘QuickSegment’)”. Still don’t know for Elastix tho.

Thanks for your help james ! Appreciate !
