# Module from console with arguments

**URL:** <https://discourse.slicer.org/t/module-from-console-with-arguments/27475>\
**Category:** Support\
**Created:** [January 26, 2023, 9:27am UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475 "2023-01-26T09:27:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucas\_sd](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lucas_sd/32/17087_2.png) [@lucas\_sd](https://discourse.slicer.org/u/lucas_sd)\
**Post date:** [January 26, 2023, 9:27am UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475/1 "2023-01-26T09:27:56Z")

</div>

Hi everybody,

I run a specific module using the terminal like this: `Slicer.exe --python-code selectModule('MyModule')`.

Now, the code of the module take arguments (-t), and I try to run the module just adding: `Slicer.exe --python-code selectModule('MyModule') -t 44`

But it doenst work, the argument is not taken (‘NoneType’), so its possible to run a module with arguments in this way? and which is the correct syntax?

Thanks a lot,  
Lucas.

---

<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:** [January 26, 2023, 11:44pm UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475/2 "2023-01-26T23:44:05Z")

</div>

Is it a scripted CLI module or a scripted Loadable module?

---

<div class="post-metadata">

**Author:** ![lucas\_sd](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lucas_sd/32/17087_2.png) [@lucas\_sd](https://discourse.slicer.org/u/lucas_sd)\
**Post date:** [January 27, 2023, 9:25am UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475/3 "2023-01-27T09:25:16Z")

</div>

Hi Andras,

Its just a scripted loadable module.

Thanks+

---

<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:** [January 28, 2023, 5:52pm UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475/4 "2023-01-28T17:52:07Z")

</div>

You can then simply list all the commands you want to launch at startup, separated by semicolons. If you want to submit many commands or you would like to avoid messing with proper quotation marks and indentation then you can specify a Python script filename to launch at startup.

If you want to interact with the application after it is started (load more data, remove data, etc) then you can use Slicer’s REST API.

There is a Python package - [slicerio](https://pypi.org/project/slicerio) - that you can pip install very easily into any Python environment that allows you to start Slicer, load data, view data, export data, etc. using a few simple Python function calls. If you find that some features are missing then feel free to add them and submit pull requests.

---

<div class="post-metadata">

**Author:** ![lucas\_sd](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lucas_sd/32/17087_2.png) [@lucas\_sd](https://discourse.slicer.org/u/lucas_sd)\
**Post date:** [January 30, 2023, 9:34am UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475/5 "2023-01-30T09:34:59Z")

</div>

> [@lassoan](#):
>
> separated by semicolons

Hi Andras, I tried like this, but it didnt work:

```auto
Slicer.exe --python-code selectModule('MyModule'); -t 20

```

In this case “t” is an argument which modify a specific action of the module. The use the semicolons is correct in this case?

Thanks+

---

<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:** [January 30, 2023, 4:42pm UTC](https://discourse.slicer.org/t/module-from-console-with-arguments/27475/6 "2023-01-30T16:42:40Z")

</div>

You can use `--python-code` to specify all parameters and actions by multiple Python commands, separated by semicolons, quoted if contains spaces. For example:

```auto
Slicer.exe --python-code "selectModule('SampleData'); getModuleGui('SampleData').setCategoryVisible('BuiltIn', False)"

```

Alternatively, you can use `--python-script` to specify a launcher script and set each additional parameter as a separate command-line argument. You can parse the arguments using Python argparse as usual. For example:

```auto
Slicer.exe --python-script path/to/BatchStructureSetConversion.py --input-folder input/folder/path --output-folder output/folder/path

```

You can find a complete example of a script that is launched like this [here](https://github.com/SlicerRt/SlicerRT/blob/master/BatchProcessing/_readme.txt).
