wsherman
(William Sherman)
April 24, 2020, 2:29am
1
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
mwestphal
(Mathieu Westphal (Kitware))
April 24, 2020, 2:32am
2
This is called a macro. Just create your script, then Tools -> Add Macros -> select your script.
wsherman
(William Sherman)
April 24, 2020, 2:41am
3
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
mwestphal
(Mathieu Westphal (Kitware))
April 24, 2020, 4:52am
4
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.
wsherman
(William Sherman)
April 24, 2020, 4:58am
5
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
mwestphal
(Mathieu Westphal (Kitware))
April 24, 2020, 5:06am
6
Only by renaming the python file and then adding the macro.
wsherman
(William Sherman)
April 24, 2020, 5:10am
7
Yep, figured that might be the case. (I was hoping I might be able to put something like a toggle state in the name.)