Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add custom nodes to 'Add' and right-click menus #217

Open
Faberix opened this issue Jun 11, 2020 · 2 comments
Open

[Feature request] Add custom nodes to 'Add' and right-click menus #217

Faberix opened this issue Jun 11, 2020 · 2 comments

Comments

@Faberix
Copy link

Faberix commented Jun 11, 2020

It would be great to have an option to save (custom) nodes that you often need and then be able to access them using the Menu. This would be a lot more convenient than having to create a new script node (or whatever other base node you are using) and then copy the code you want or write new code each time you need it.
Adding a node to the saved nodes could be done using a GUI like in the sketch below:
Antimony custom node in menu proposal GUI sketch
It could be accessed using a new entry in the right click menu when right clicked on a node and/or using a new entry (e.g. "Edit available nodes") in either the "Edit" or the "Add" menu.

Implementing the dynamic addition/removal of menu items should not be difficult; it can be done using QMenu.addAction, QMenu.removeAction and QMenu.insertAction (of course, the nodes and the order would have to be saved in the program data and the menus would have to be adjusted accordingly on each program startup).

Saving the additional nodes in the program data should also not be a problem, as the nodes should actually be fully defined by their Python code snippet.

One node that would be useful to have accessible would be the following node (that evaluates an arbitrary mathematical expression in Python code):

import fab
import math

varTuple = ('a', 'b')

title('formula')
for v in varTuple:
	input(v, float)
input('formula', str)

out = eval(formula)
output('out', out)

@Faberix Faberix changed the title Add custom nodes to 'Add' and right-click menus [Feature request] Add custom nodes to 'Add' and right-click menus Jun 11, 2020
@mkeeter
Copy link
Owner

mkeeter commented Jun 11, 2020

It's already possible to install (global) custom nodes: when populating the node menu here, we search for files in the nodes subfolder of AppDataLocation, which is platform-specific.

Does that accomplish what you're looking for, or do you specifically want to store extra nodes on a per-file basis? It would also be useful to have a UI for saving a new global node, which would be welcome in a PR.

@Faberix
Copy link
Author

Faberix commented Jun 11, 2020

Does that accomplish what you're looking for, or do you specifically want to store extra nodes on a per-file basis?

Yes, it does.
As for the UI, I will not have time for that any time soon (I already have too many other projects running). In case anyone else wants to implement it: I noticed that the nodes are stored in /usr/share/antimony (at least in Ubuntu), which is read-only (except for root, of course). So, if a node should be stored from GUI, QStandardPaths::writableLocation should be used for all custom nodes.

I will leave this issue open, as the GUI would still be useful (especially because the option of manually creating the files will probably not be discovered by most users). Feel free to close it, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants