# Possible to use a Python Plugin to add a button to the tool bars?

**URL:** https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164
**Category:** ParaView Support
**Created:** [April 24, 2020, 2:29am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164 "2020-04-24T02:29:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![wsherman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8797f3/32.png) [@wsherman](https://discourse.paraview.org/u/wsherman)
#### Post date: [April 24, 2020, 2:29am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/1 "2020-04-24T02:29:12Z")

</div>

Hello all,

I’m doing some experimenting with simple Python Plugins in ParaView – trying to avoid the need to do any compiling (not so much for me, but for the people I’m helping).

If possible, I’d like to be able to add a button to the tool bar at the top to run a python script – rather than typing in the command in the Python Shell. For a simple example, I might want to do this:  
` servermanager.GetRenderView().ShowAnnotation = 1`

Is this doable? I haven’t been able to find examples of this via Google.

Thanks, Bill

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 24, 2020, 2:32am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/2 "2020-04-24T02:32:39Z")

</div>

This is called a macro. Just create your script, then Tools -\> Add Macros -\> select your script.

---

<div class="post-metadata">

### Author: ![wsherman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8797f3/32.png) [@wsherman](https://discourse.paraview.org/u/wsherman)
#### Post date: [April 24, 2020, 2:41am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/3 "2020-04-24T02:41:45Z")

</div>

Aha, I was googling the wrong term.

Is there a way to set the icon in the Python file?  
Edit: also, is there a way to set the name, and perhaps change it based on the state of the macro?

Also, in 5.8.0 it’s not under “Tools”, but under it’s own top menu “Macros” (for people reading this in the future).

Thanks!  
Bill

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 24, 2020, 4:52am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/4 "2020-04-24T04:52:01Z")

</div>

Sadly no, there is no way to use a custom icon with macros that is only doable with a Qt C++ plugin.  
That would be a nice small feature to add though.

Indeed, you are correct about the location of the option.

---

<div class="post-metadata">

### Author: ![wsherman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8797f3/32.png) [@wsherman](https://discourse.paraview.org/u/wsherman)
#### Post date: [April 24, 2020, 4:58am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/5 "2020-04-24T04:58:53Z")

</div>

Thanks again Mathieu,

I have one final followup (I’d added it to the last followup as an Edit, so it might not have appeared in your message):

Is there a way to set and then even change the text string that shows up on the Tool bar?

Thanks yet again, Bill

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 24, 2020, 5:06am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/6 "2020-04-24T05:06:58Z")

</div>

Only by renaming the python file and then adding the macro.

---

<div class="post-metadata">

### Author: ![wsherman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8797f3/32.png) [@wsherman](https://discourse.paraview.org/u/wsherman)
#### Post date: [April 24, 2020, 5:10am UTC](https://discourse.paraview.org/t/possible-to-use-a-python-plugin-to-add-a-button-to-the-tool-bars/4164/7 "2020-04-24T05:10:21Z")

</div>

Yep, figured that might be the case. (I was hoping I might be able to put something like a toggle state in the name.)
