From 5f91488f85d2ca3ca470ca78e341aff1261dad6e Mon Sep 17 00:00:00 2001 From: XchanBik Date: Sat, 10 May 2025 17:00:31 +0200 Subject: [PATCH] Update Text.py --- Text.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Text.py b/Text.py index 953293d..736def5 100644 --- a/Text.py +++ b/Text.py @@ -1 +1,27 @@ cat = "XchanBik/Text" + +import os + +class TextLoadNode: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "file_path": ("STRING", {"default": "base.txt"}), # Path to your text file + } + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("loaded_text",) + FUNCTION = "load_text_from_file" + CATEGORY = cat + + def load_text_from_file(self, file_path): + if not os.path.exists(file_path): + print(f"Error: File {file_path} not found.") + return ("",) # Return an empty string if the file is not found + + with open(file_path, "r") as file: + loaded_text = file.read() + + return (loaded_text,) # Return the content of the text file as a string