-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtext_input.py
More file actions
59 lines (49 loc) · 1.75 KB
/
text_input.py
File metadata and controls
59 lines (49 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class FlexibleInputs(dict):
# 已移除 BGCOLOR 和 COLOR
"""A special class to make flexible node inputs."""
def __init__(self, type):
self.type = type
def __getitem__(self, key):
return (self.type, )
def __contains__(self, key):
return True
class TextInput:
# 已移除 BGCOLOR 和 COLOR
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"separator": ("STRING", {"default": " "})
},
"optional": {
# First 3 inputs as connection points
"text1": ("STRING",),
"text2": ("STRING",),
"text3": ("STRING",),
# Last 4 inputs as text fields
"text4": ("STRING", {"default": ""}),
"text5": ("STRING", {"default": ""}),
"text6": ("STRING", {"default": ""}),
"text7": ("STRING", {"default": ""})
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "join_texts"
CATEGORY = "ComfyUI Text Processor"
def join_texts(self, separator, text1="", text2="", text3="", text4="", text5="", text6="", text7=""):
# Filter out empty strings
texts = [t for t in [text1, text2, text3, text4, text5, text6, text7] if t]
# If no inputs are provided, return the default message
if not texts:
return ("A cute little monster holding a sign with big text: GIVE ME INPUT!",)
# Join the non-empty texts with the separator
result = separator.join(texts)
return (result,)
NODE_CLASS_MAPPINGS = {
"TextInput": TextInput
}
NODE_DISPLAY_NAME_MAPPINGS = {
"TextInput": "Text Input Node"
}