From 5c0c8719144a701b2cf4a2f4a9d2aaf27eed1d9e Mon Sep 17 00:00:00 2001 From: Levi Date: Mon, 12 May 2025 03:47:37 +0000 Subject: [PATCH] first commit --- README.md | 16 +++++++++++- __init__.py | 3 +++ nodes.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 __init__.py create mode 100644 nodes.py diff --git a/README.md b/README.md index 6b39662..3069725 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # ComfyUI-FormInput -ComfyUI simple input nodes + +This custom node for ComfyUI provides a set of input elements to create forms or interact with your workflows. + +## Nodes + +- **Text Input (FormInput)**: Allows you to input single-line or multi-line text. +- **Boolean Input (FormInput)**: Provides a toggle switch for true/false values. +- **Display Text (FormInput)**: Shows text output within a node. + +## Installation + +1. Clone this repository into your `ComfyUI/custom_nodes/` directory. +2. Restart ComfyUI. + +You should find the nodes under the "FormInput" category. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..3d998ea --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] diff --git a/nodes.py b/nodes.py new file mode 100644 index 0000000..d20e497 --- /dev/null +++ b/nodes.py @@ -0,0 +1,70 @@ +class TextInputNode: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text": ("STRING", {"multiline": True, "default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("text",) + FUNCTION = "process_text" + CATEGORY = "FormInput" + + def process_text(self, text): + return (text,) + + +class BooleanInputNode: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "boolean": ("BOOLEAN", {"default": True, "label_on": "True", "label_off": "False"}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + RETURN_NAMES = ("boolean_output",) + FUNCTION = "process_boolean" + CATEGORY = "FormInput" + + def process_boolean(self, boolean): + return (boolean,) + + +class DisplayTextNode: + OUTPUT_NODE = True # Mark as an output/display node + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text_to_display": ("STRING", {"multiline": True, "default": "Text to display"}), + } + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("displayed_text",) + FUNCTION = "display_the_text" + OUTPUT_NODE = True + CATEGORY = "FormInput" + + def display_the_text(self, text_to_display): + # This structure allows the text to be shown in the node's UI (if supported) + # and also passes the text as a regular output. + return {"ui": {"text": [text_to_display]}, "result": (text_to_display,)} + + +NODE_CLASS_MAPPINGS = { + "TextInput_FormInput": TextInputNode, + "BooleanInput_FormInput": BooleanInputNode, + "DisplayText_FormInput": DisplayTextNode, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "TextInput_FormInput": "Text Input (FormInput)", + "BooleanInput_FormInput": "Boolean Input (FormInput)", + "DisplayText_FormInput": "Display Text (FormInput)", +}