Files
2026-03-14 12:20:51 +09:00

43 lines
1.3 KiB
Python

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": ("",)}