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

Add support for DISPLAY_NAME in custom nodes #2633

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions custom_nodes/example_node.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Example:
If this node is an output node that outputs a result/image from the graph. The SaveImage node is an example.
The backend iterates on these output nodes and tries to execute all their parents if their parent graph is properly connected.
Assumed to be False if not present.
DISPLAY_NAME (`str`):
A friendly/humanly readable title for the node.
CATEGORY (`str`):
The category the node should appear in the UI.
execute(s) -> tuple || None:
Expand Down Expand Up @@ -76,6 +78,7 @@ class Example:

#OUTPUT_NODE = False

DISPLAY_NAME = "Example Node"
CATEGORY = "Example"

def test(self, image, string_field, int_field, float_field, print_to_screen):
Expand All @@ -97,6 +100,7 @@ NODE_CLASS_MAPPINGS = {
}

# A dictionary that contains the friendly/humanly readable titles for the nodes
# NOTE: This is the same as using the DISPLAY_NAME property
NODE_DISPLAY_NAME_MAPPINGS = {
"Example": "Example Node"
}
2 changes: 1 addition & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def node_info(node_class):
info['output_is_list'] = obj_class.OUTPUT_IS_LIST if hasattr(obj_class, 'OUTPUT_IS_LIST') else [False] * len(obj_class.RETURN_TYPES)
info['output_name'] = obj_class.RETURN_NAMES if hasattr(obj_class, 'RETURN_NAMES') else info['output']
info['name'] = node_class
info['display_name'] = nodes.NODE_DISPLAY_NAME_MAPPINGS[node_class] if node_class in nodes.NODE_DISPLAY_NAME_MAPPINGS.keys() else node_class
info['display_name'] = obj_class.DISPLAY_NAME if hasattr(obj_class,'DISPLAY_NAME') else nodes.NODE_DISPLAY_NAME_MAPPINGS[node_class] if node_class in nodes.NODE_DISPLAY_NAME_MAPPINGS.keys() else node_class
info['description'] = obj_class.DESCRIPTION if hasattr(obj_class,'DESCRIPTION') else ''
info['category'] = 'sd'
if hasattr(obj_class, 'OUTPUT_NODE') and obj_class.OUTPUT_NODE == True:
Expand Down