Update Text.py

This commit is contained in:
XchanBik
2025-05-10 17:00:31 +02:00
committed by GitHub
parent 62c1109219
commit 5f91488f85
+26
View File
@@ -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