# getting the code of Python

**URL:** <https://discourse.slicer.org/t/getting-the-code-of-python/13682>\
**Category:** Development\
**Tags:** build, extensions-manager, python\
**Created:** [September 24, 2020, 12:07am UTC](https://discourse.slicer.org/t/getting-the-code-of-python/13682 "2020-09-24T00:07:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldoSanchez](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aldoSanchez](https://discourse.slicer.org/u/aldoSanchez)\
**Post date:** [September 24, 2020, 12:07am UTC](https://discourse.slicer.org/t/getting-the-code-of-python/13682/1 "2020-09-24T00:07:24Z")

</div>

hello  
I want to know if someone knows how to see all commands that I’m executing in 3D slicer.  
I mean doing an action and seen the code of that accion.

---

<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:** [September 24, 2020, 12:09pm UTC](https://discourse.slicer.org/t/getting-the-code-of-python/13682/2 "2020-09-24T12:09:26Z")

</div>

There’s no direct mapping between user actions and python code.

You can look at some of the [Self Tests](https://github.com/Slicer/Slicer/tree/master/Applications/SlicerApp/Testing/Python) will give you some ideas about how to control the application via python. Other than that the process is basically to study the source code to find how any particular feature is implemented and follow the same pattern. Sometimes this means mapping from C++ to Python, but usually that part is obvious.

---

<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:** [September 24, 2020, 12:52pm UTC](https://discourse.slicer.org/t/getting-the-code-of-python/13682/3 "2020-09-24T12:52:30Z")

</div>

We also provide code snippets for all commonly needed tasks in the [script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository) and if you don’t find something then you can just ask here.

---

<div class="post-metadata">

**Author:** ![aldoSanchez](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aldoSanchez](https://discourse.slicer.org/u/aldoSanchez)\
**Post date:** [September 24, 2020, 5:29pm UTC](https://discourse.slicer.org/t/getting-the-code-of-python/13682/4 "2020-09-24T17:29:32Z")

</div>

thanks for the information,  
I’m trying to work with pure python command lines, I don’t want to use the Qt  
the idea is to run everything from a script.

---

<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:** [September 24, 2020, 11:29pm UTC](https://discourse.slicer.org/t/getting-the-code-of-python/13682/5 "2020-09-24T23:29:59Z")

</div>

You can use everything from a script, including using Qt classes. Rendering may require an application window (it can be hidden, but it has to exist). You can also use Slicer as Jupyter notebook kernel.
