Names and tooltip for ParaView macro

We’re planning to extend macros with more information:

  1. Display a tooltip text when mouse hovers above the macro icon in the user interface.

  2. Add ability to name macros and display the name in macro manager dialog. Ideally, some convention is required here - the name and tooltip could be parsed from the first few lines of the script only when they are comments with a specific format.
    For example, I think this is a good start:

    # macro_name: HighResCylinder
    # macro_tooltip_text: high resolution cylinder
    # macro_icon: /path/to/icon
    ...
    

    macro_icon is optional.

  3. Modify pqPythonManager::executeCode() to display the first line of the python script (excluding shebang?) in the dialog window title.

@mwestphal, @cory.quammen what do you think?

Yes, this sounds good.

Ideally you could change the name and tooltip in the Edit Macros panel that is in ParaView master. Currently, it shows only the macro name, which is not editable, and icon.

We could make the macro name editable, and add a second column that let’s you modify the tooltip text. The name and tooltip info could be saved wherever the icon file name is saved, probably in settings?

This idea predates the existence of the Edit Macros window. It could be considered as a way to initialize the name, tooltip, and icon, but that might not be necessary.

To clarify: Python Macros can take user input with the Python input() function call. That function accepts a an optional message that is currently only printed to the Python console. The intent of this change would be to take that message and show it somehow on the dialog window that currently looks like

That is, if we call input("Enter a radius"), the dialog title or where it currently says “Input:” would instead say “Enter a radius”.

Wooo, I didn’t know that! Indeed, should be nice to specify the prompt.

Editing macros name and tooltip sounds fine. Tooltip should default to the name and name should default to filename (without extension?), IMO.

Also, not sure of the use case of having those meta data inside the python script.

Nice, please make it configurable in the macro editor.

Ideally you could change the name and tooltip in the Edit Macros panel that is in ParaView master. Currently, it shows only the macro name, which is not editable, and icon.

Yes please :slight_smile:

the name and tooltip could be parsed from the first few lines of the script only when they are comments with a specific format.

That doesnt sound like a good idea to me. The macro should ideally be only a python script and meta data about it should be stored in the settings. If needed, a import/export feature could be added to handle metadata and scripts somehow.

Lets try not to mix metadata with data.

Thanks for your feedback!

Yes. That is a reasonable default.

This is a customer request, so are there similar alternatives? They’d like ParaView macro scripts to follow a convention that specifies the macro name and tooltip text with the intention of having ParaView macro manager display these under the “Name” and “Tooltip text” in the UI, overriding the defaults as alluded to by @nicolas.vuaille

Such metainformation should be stored in the settings and imported/exported with a dedicated .json based format.

Such json file could even contains multiple macros information including the scripts themselves.

Got name and tooltip editing to work. Earlier, you could double click on the macro column and a script editor would open up allowing a user to edit python code. However, since we made macro names editable, the old behavior cannot be sandwiched in here directly.

What are your thoughts on showing a button at the end of the macro column which when clicked opens up a code editor? Taking inspiration from programmable filters.

2 Likes

Sounds fine to me