From 003dc051cd992ec1710466f40af6f0bab5b84dd3 Mon Sep 17 00:00:00 2001 From: "Lex Darlog (DRL)" <3897975+Lex-DRL@users.noreply.github.com> Date: Mon, 7 Jul 2025 15:24:15 +0500 Subject: [PATCH] scaffolding for `show` toggle: currently, there's no point in it --- _funcs.py | 10 ++++++++-- nodes.py | 45 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/_funcs.py b/_funcs.py index be43f51..cd0cbc3 100644 --- a/_funcs.py +++ b/_funcs.py @@ -138,7 +138,7 @@ def format_report( def simple_result_from_approx_wh( - width_f: float, height_f: _t_number, step: int, + width_f: float, height_f: _t_number, step: int, show: bool = True, unique_id: str = None, target_square_size: _t_number = None ): """Final part of the main func for simple (non-upscale) nodes - when desired float/height are already calculated""" @@ -146,7 +146,13 @@ def simple_result_from_approx_wh( width, n_steps_x, height, n_steps_y = round_width_and_height_closest_to_the_ratio(width_f, height_f, step) if unique_id: - text = format_report(width_f, height_f, step, width, n_steps_x, height, n_steps_y, target_square_size) + text = ( + format_report(width_f, height_f, step, width, n_steps_x, height, n_steps_y, target_square_size) + if show + # TODO: Planned for the future - currently, there's no point removing the text since it's box is shown anyway + else '' # An odd workaround since `send_progress_text()` doesn't want to update text when '' passed + ) + # print(f"{unique_id} text: {text!r}") # Snatched from: https://github.com/comfyanonymous/ComfyUI/blob/27870ec3c30e56be9707d89a120eb7f0e2836be1/comfy_extras/nodes_images.py#L581-L582 _PromptServer.instance.send_progress_text(text, unique_id) diff --git a/nodes.py b/nodes.py index e48489d..9641d92 100644 --- a/nodes.py +++ b/nodes.py @@ -37,6 +37,11 @@ _input_types_simple = deepfreeze({ "by 3 AND 9, which might become handy at that point, where you'll probably use UltimateSDUpscale.\n\n" "Other values worth trying first: 64, 96, 128." )})), + # 'show': (_IO.BOOLEAN, { + # 'default': True, + # # 'label_on': 'on', 'label_off': 'off', + # 'tooltip': "Show the result on the node itself?", + # }), }, 'hidden': { 'unique_id': 'UNIQUE_ID', # used for text display at the bottom of the node @@ -70,8 +75,16 @@ class BestResolutionSimple: def INPUT_TYPES(cls): return _input_types_simple - def main(self, width: int, height: int, step: int, unique_id: str = None): - return _simple_result_from_approx_wh(float(width), height, step, unique_id, _sqrt(width * height)) + def main( + self, width: int, height: int, step: int, + # show: bool, + unique_id: str = None + ): + return _simple_result_from_approx_wh( + float(width), height, step, + # show, + unique_id=unique_id, target_square_size=_sqrt(width * height) + ) _tooltip_aspect = ( @@ -106,6 +119,7 @@ _input_types_orient = deepfreeze({ 'default': 9.0, 'min': 1.0, 'max': _sys.float_info.max, 'step': 1.0, 'round': 0.001, 'tooltip': _tooltip_aspect }), + # 'show': _input_types_simple['required']['show'], }, 'hidden': { 'unique_id': 'UNIQUE_ID', @@ -133,7 +147,12 @@ class BestResolutionFromAspectRatio: def INPUT_TYPES(cls): return _input_types_orient - def main(self, size: int, step: int, size_is_big: bool, landscape: bool, aspect_a: float, aspect_b: float, unique_id: str = None): + def main( + self, + size: int, step: int, size_is_big: bool, landscape: bool, aspect_a: float, aspect_b: float, + # show: bool, + unique_id: str = None + ): aspect_big, aspect_small = _aspect_ratios_sorted(aspect_a, aspect_b) side_main_f = float(size) @@ -146,7 +165,11 @@ class BestResolutionFromAspectRatio: # The opposite: height is bigger width_f, height_f = height_f, width_f - return _simple_result_from_approx_wh(width_f, height_f, step, unique_id, _sqrt(width_f * height_f)) + return _simple_result_from_approx_wh( + width_f, height_f, step, + # show, + unique_id=unique_id, target_square_size=_sqrt(width_f * height_f) + ) _input_types_area = deepfreeze({ @@ -162,6 +185,7 @@ _input_types_area = deepfreeze({ 'landscape': _input_types_orient['required']['landscape'], 'aspect_a': _input_types_orient['required']['aspect_a'], 'aspect_b': _input_types_orient['required']['aspect_b'], + # 'show': _input_types_simple['required']['show'], }, 'hidden': { 'unique_id': 'UNIQUE_ID', @@ -198,7 +222,16 @@ class BestResolutionFromArea: def INPUT_TYPES(cls): return _input_types_area - def main(self, square_size: int, step: int, landscape: bool, aspect_a: float, aspect_b: float, unique_id: str = None): + def main( + self, + square_size: int, step: int, landscape: bool, aspect_a: float, aspect_b: float, + # show: bool, + unique_id: str = None + ): square_size: int = _number_to_int(square_size) width_f, height_f = _float_width_height_from_area(square_size, landscape, aspect_a, aspect_b) - return _simple_result_from_approx_wh(width_f, height_f, step, unique_id, square_size) + return _simple_result_from_approx_wh( + width_f, height_f, step, + # show, + unique_id=unique_id, target_square_size=square_size + )