# Names and tooltip for ParaView macro

**URL:** https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954
**Category:** Development
**Created:** [February 16, 2024, 3:53pm UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954 "2024-02-16T15:53:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jaswantp/32/11456_2.png) [@jaswantp](https://discourse.paraview.org/u/jaswantp)
#### Post date: [February 16, 2024, 3:53pm UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/1 "2024-02-16T15:53:41Z")

</div>

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:

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?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [February 16, 2024, 9:32pm UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/2 "2024-02-16T21:32:14Z")

</div>

> [@jaswantp](#):
>
> - Display a tooltip text when mouse hovers above the macro icon in the user interface.

Yes, this sounds good.

> [@jaswantp](#):
>
> Add ability to name macros and display the name in macro manager dialog.

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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/6/695d2d6ddb062f1b6bc5938af683737a00c309f8.png)

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?

> [@jaswantp](#):
>
> the name and tooltip could be parsed from the first few lines of the script only when they are comments with a specific format.

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.

> [@jaswantp](#):
>
> Modify **pqPythonManager::executeCode()** to display the first line of the python script (excluding shebang?) in the dialog window title.

> [@jaswantp](#):
>
> Modify **pqPythonManager::executeCode()** to display the first line of the python script (excluding shebang?) in the dialog window title.

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

 ![image](https://discourse.paraview.org/uploads/default/original/2X/c/c8638958962649112a806973322d32b8ddbb3c65.png)

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

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 19, 2024, 8:44am UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/3 "2024-02-19T08:44:12Z")

</div>

> [@cory.quammen](#):
>
> Python Macros can take user input with the Python `input()` function call

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.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 19, 2024, 8:59am UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/4 "2024-02-19T08:59:53Z")

</div>

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

---

<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: [February 19, 2024, 9:53am UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/5 "2024-02-19T09:53:29Z")

</div>

> [@jaswantp](#):
>
> Display a tooltip text when mouse hovers above the macro icon in the user interface.

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 🙂

> 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.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jaswantp/32/11456_2.png) [@jaswantp](https://discourse.paraview.org/u/jaswantp)
#### Post date: [February 19, 2024, 2:54pm UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/6 "2024-02-19T14:54:59Z")

</div>

Thanks for your feedback!

> [@nicolas.vuaille](#):
>
> Tooltip should default to the name and name should default to filename (without extension?), IMO.

Yes. That is a reasonable default.

> [@nicolas.vuaille](#):
>
> Also, not sure of the use case of having those meta data inside the python script.

> [@mwestphal](#):
>
> 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.

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

---

<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: [February 19, 2024, 2:58pm UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/7 "2024-02-19T14:58:28Z")

</div>

> [@jaswantp](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jaswantp/32/11456_2.png) [@jaswantp](https://discourse.paraview.org/u/jaswantp)
#### Post date: [February 22, 2024, 6:25pm UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/8 "2024-02-22T18:25:48Z")

</div>

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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/1/11f93a22db6da67be68f04f76739452d1a51132c.png)

---

<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: [February 23, 2024, 8:18am UTC](https://discourse.paraview.org/t/names-and-tooltip-for-paraview-macro/13954/9 "2024-02-23T08:18:42Z")

</div>

Sounds fine to me
