-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsingle_line_picker.py
More file actions
42 lines (33 loc) · 1.35 KB
/
single_line_picker.py
File metadata and controls
42 lines (33 loc) · 1.35 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
class AnyType(str):
"""A special class that is always equal in not equal comparisons. Credit to pythongosssss"""
def __ne__(self, __value: object) -> bool:
return False
any_type = AnyType("*")
class SLPSingleLinePicker:
NAME = "HetimaSingleLinePicker"
DISPLAY_NAME = "SLP List View"
CATEGORY = "SingleLinePicker"
DESCRIPTION = "Select one line from the text list with a single click."
@classmethod
def INPUT_TYPES(cls):
return {
"optional": {
"text": ("STRING", {"multiline": True, "default": "", "forceInput": True, "tooltip": "text content for list"}),
},
"hidden": {
"source_text": ("STRING", {}),
"selected_text": ("STRING", {}),
# "stem": ("STRING", {}),
},
}
RETURN_TYPES = (any_type,)
RETURN_NAMES = ("selection",)
OUTPUT_TOOLTIPS = ("text content of selected line",)
OUTPUT_NODE = True
FUNCTION = "executed"
def executed(self, text=None, source_text=None, selected_text=None, **kwargs):
if not text:
return {"ui": { "text": source_text }, "result": (selected_text,)}
if text == source_text:
return {"ui": { "text": source_text }, "result": (selected_text,)}
return {"ui": { "text": text }, "result": ("",)}