mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-06-02 08:46:37 +08:00
Change WidgetToString to use the any_input link if no id or title.
If no node if or title is provided use the link to get the node id.
This commit is contained in:
parent
3c0bc27343
commit
cc6196c25f
@ -711,17 +711,17 @@ class WidgetToString:
|
|||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"id": ("INT", {"default": 0}),
|
|
||||||
"widget_name": ("STRING", {"multiline": False}),
|
"widget_name": ("STRING", {"multiline": False}),
|
||||||
"return_all": ("BOOLEAN", {"default": False}),
|
"return_all": ("BOOLEAN", {"default": False}),
|
||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
"any_input": (any, {}),
|
"any_input": (any, {}),
|
||||||
|
"id": ("INT", {"default": 0}),
|
||||||
"node_title": ("STRING", {"multiline": False}),
|
"node_title": ("STRING", {"multiline": False}),
|
||||||
},
|
},
|
||||||
|
|
||||||
"hidden": {"extra_pnginfo": "EXTRA_PNGINFO",
|
"hidden": {"extra_pnginfo": "EXTRA_PNGINFO",
|
||||||
"prompt": "PROMPT"},
|
"prompt": "PROMPT",
|
||||||
|
"unique_id": "UNIQUE_ID",},
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("STRING", )
|
RETURN_TYPES = ("STRING", )
|
||||||
@ -729,14 +729,14 @@ class WidgetToString:
|
|||||||
CATEGORY = "KJNodes/text"
|
CATEGORY = "KJNodes/text"
|
||||||
DESCRIPTION = """
|
DESCRIPTION = """
|
||||||
Selects a node and it's specified widget and outputs the value as a string.
|
Selects a node and it's specified widget and outputs the value as a string.
|
||||||
|
If no node id or title is provided it will use the 'any_input' link and use that node.
|
||||||
To see node id's, enable node id display from Manager badge menu.
|
To see node id's, enable node id display from Manager badge menu.
|
||||||
Alternatively you can search with the node title. Node titles ONLY exist if they
|
Alternatively you can search with the node title. Node titles ONLY exist if they
|
||||||
are manually edited!
|
are manually edited!
|
||||||
The 'any_input' is purely for making sure the node you want the value from exists in the workflow,
|
The 'any_input' is required for making sure the node you want the value from exists in the workflow.
|
||||||
it has no other function than place this node at right spot in the workflow execution order.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_widget_value(self, id, widget_name, extra_pnginfo, prompt, return_all=False, any_input=None, node_title=""):
|
def get_widget_value(self, widget_name, extra_pnginfo, prompt, unique_id, return_all=False, any_input=None, id=0, node_title=""):
|
||||||
workflow = extra_pnginfo["workflow"]
|
workflow = extra_pnginfo["workflow"]
|
||||||
#print(json.dumps(workflow, indent=4))
|
#print(json.dumps(workflow, indent=4))
|
||||||
results = []
|
results = []
|
||||||
@ -750,9 +750,15 @@ it has no other function than place this node at right spot in the workflow exec
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("Node title not found.")
|
print("Node title not found.")
|
||||||
elif node["id"] == id:
|
elif id != 0:
|
||||||
node_id = id
|
if node["id"] == id:
|
||||||
break
|
node_id = id
|
||||||
|
break
|
||||||
|
elif any_input:
|
||||||
|
if node["type"] == "WidgetToString" and node["id"] == int(unique_id):
|
||||||
|
for node_input in node["inputs"]:
|
||||||
|
node_id = node_input["link"]
|
||||||
|
break
|
||||||
|
|
||||||
if node_id is None:
|
if node_id is None:
|
||||||
raise ValueError("No matching node found for the given title or id")
|
raise ValueError("No matching node found for the given title or id")
|
||||||
@ -765,9 +771,9 @@ it has no other function than place this node at right spot in the workflow exec
|
|||||||
v = str(values["inputs"][widget_name]) # Convert to string here
|
v = str(values["inputs"][widget_name]) # Convert to string here
|
||||||
return (v, )
|
return (v, )
|
||||||
else:
|
else:
|
||||||
raise NameError(f"Widget not found: {id}.{widget_name}")
|
raise NameError(f"Widget not found: {node_id}.{widget_name}")
|
||||||
if not results:
|
if not results:
|
||||||
raise NameError(f"Node not found: {id}")
|
raise NameError(f"Node not found: {node_id}")
|
||||||
return (', '.join(results).strip(', '), )
|
return (', '.join(results).strip(', '), )
|
||||||
|
|
||||||
class DummyOut:
|
class DummyOut:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user