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

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

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

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

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.

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

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

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