# How to Run a Macro without cleanup python object after running

**URL:** https://discourse.paraview.org/t/how-to-run-a-macro-without-cleanup-python-object-after-running/4423
**Category:** Development
**Tags:** python
**Created:** [May 27, 2020, 6:38am UTC](https://discourse.paraview.org/t/how-to-run-a-macro-without-cleanup-python-object-after-running/4423 "2020-05-27T06:38:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [May 27, 2020, 6:38am UTC](https://discourse.paraview.org/t/how-to-run-a-macro-without-cleanup-python-object-after-running/4423/1 "2020-05-27T06:38:01Z")

</div>

Hi guys,  
I am writing a python scripts with a PyQt Dialog, It works well through pythonShell-\>run scripts, then I try to add it as a macro for convenience, It seems that PyQt object get cleanup right after macro run, and the dialog disappeared.  
So is there any way to make python object alive like InteractiveConsole?

btw, I am trying to add a custom toolbar for more friendly user experience(through this trick), it looks like this:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/1/1c8d82e7a8b69742316de85f218c662ad1d689d7.png)

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [March 18, 2021, 1:14am UTC](https://discourse.paraview.org/t/how-to-run-a-macro-without-cleanup-python-object-after-running/4423/2 "2021-03-18T01:14:45Z")

</div>

Accidentaly find the solution:)

Just load .py file containing PyQt code as a Plugin.  
If this plugin is marked auto load, then everty time ParaView startup, the dialog will show up.
