# Open a slicer module with python

**URL:** https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754
**Category:** Support
**Created:** [February 2, 2022, 4:36pm UTC](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754 "2022-02-02T16:36:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)
#### Post date: [February 2, 2022, 4:36pm UTC](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754/1 "2022-02-02T16:36:25Z")

</div>

I want to open my custom scripted module every time I open Slicer.

I know that I have to edit the .slicerrc.py file, but I don’t know what lines of code to put in there.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [February 2, 2022, 4:38pm UTC](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754/2 "2022-02-02T16:38:41Z")

</div>

As an example I add this to the command line when I start slicer:

```auto
--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: ![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 2, 2022, 4:38pm UTC](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754/3 "2022-02-02T16:38:55Z")

</div>

The Slicer script repository has many python examples that may be helpful for you. One includes setting the slicer module for startup.

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#set-a-new-default-module-at-startup](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#set-a-new-default-module-at-startup)

---

<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 2, 2022, 4:48pm UTC](https://discourse.slicer.org/t/open-a-slicer-module-with-python/21754/4 "2022-02-02T16:48:49Z")

</div>

Using the GUI, you can go to Settings-\>Modules and set the Default startup module from the list of loaded modules. Here I have set “OpenIGTLinkIF” as my new default.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/b/fb120dbc07dd0541e38d8248a242edd1ce7cfb5d.png)
