From 7e314b0ffbc6a5b54be11bcc8dfdfbae94230ed6 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Sun, 4 Jun 2023 14:38:54 -0400 Subject: [PATCH] updates to eval widget, now a bit easier to understand usage. also more to come! --- image.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/image.py b/image.py index abacc46..27c14b6 100644 --- a/image.py +++ b/image.py @@ -330,14 +330,14 @@ class ExecWidget: }, "required": { - "name": ("STRING", {"multiline": False, - "default": "exec_func"} + "CODE_STR_IN": ("STRING", {"multiline": False, + "default": ""} ), } } CATEGORY = "text" - RETURN_TYPES = ("STRING", "IMAGE", "FLOAT", "INT", "TUPLE") + RETURN_TYPES = ("STRING", "IMAGE", "FLOAT", "INT", "TUPLE","CODE") FUNCTION = "exec_handler" INTERNAL_STATE_DISPLAY_CODE = True @@ -376,6 +376,7 @@ class ExecWidget: text_to_eval = text_to_eval[start + 8:end] exec(text_to_eval, globals(), new_locals) + source_code = text_to_eval string_out = new_locals.get("string_out", None) image_out = new_locals.get("image_out", None) @@ -386,7 +387,7 @@ class ExecWidget: except Exception as e: string_out = str(e) - return (string_out, image_out, float_out, int_out, tuple_out,) + return (string_out, image_out, float_out, int_out, tuple_out,source_code) @classmethod def IS_CHANGED(s, text_to_eval, image1_in: torch.Tensor = None, float1_in: float = 0.0, string1_in: str = "",