# Call a macro by python code

**URL:** <https://discourse.slicer.org/t/call-a-macro-by-python-code/17373>\
**Category:** Development\
**Tags:** python\
**Created:** [April 28, 2021, 8:03pm UTC](https://discourse.slicer.org/t/call-a-macro-by-python-code/17373 "2021-04-28T20:03:57Z")\
**Posts on this page:** 4\
**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:** [April 28, 2021, 8:03pm UTC](https://discourse.slicer.org/t/call-a-macro-by-python-code/17373/1 "2021-04-28T20:03:57Z")

</div>

I want to know if there is a way to run a macro with a python comando

---

<div class="post-metadata">

**Author:** ![Isabella\_Romero](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/isabella_romero/32/15865_2.png) [@Isabella\_Romero](https://discourse.slicer.org/u/Isabella_Romero)\
**Post date:** [September 21, 2022, 10:05am UTC](https://discourse.slicer.org/t/call-a-macro-by-python-code/17373/2 "2022-09-21T10:05:50Z")

</div>

Hi, I want to know that too. Did you figure it out?

---

<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 21, 2022, 2:31pm UTC](https://discourse.slicer.org/t/call-a-macro-by-python-code/17373/3 "2022-09-21T14:31:12Z")

</div>

It’s not clear what kind of macro you are referring to. The script repository has a lot of examples of automating actions.

---

<div class="post-metadata">

**Author:** ![Isabella\_Romero](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/isabella_romero/32/15865_2.png) [@Isabella\_Romero](https://discourse.slicer.org/u/Isabella_Romero)\
**Post date:** [September 21, 2022, 5:19pm UTC](https://discourse.slicer.org/t/call-a-macro-by-python-code/17373/4 "2022-09-21T17:19:33Z")

</div>

Hi,  
I recorded a macro in 3D slicer using the Qttesting enable mode. I saved it as an xml file. I know how to play it from 3D slicer using the Play Macro button under Edit. But I was wondering if there is any python code or sentence that can be used to play the macro
