From 38018edd1b2fda31c613553a499b71d5f138b3d9 Mon Sep 17 00:00:00 2001 From: LEv145 Date: Sun, 23 Apr 2023 16:13:00 +0200 Subject: [PATCH] v 2.3.2 Add multiply lines in `GridAnnotationNode` Fix typing Add `COLUMNS_COUNT`, `ROWS_COUNT` for `GridAnnotationNode` output --- src/nodes/grid_annotation.py | 13 +++++++------ src/nodes/image_combine.py | 2 +- src/nodes/images_grid.py | 2 +- src/nodes/latent_combine.py | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/nodes/grid_annotation.py b/src/nodes/grid_annotation.py index e1ddce2..ace3ab3 100644 --- a/src/nodes/grid_annotation.py +++ b/src/nodes/grid_annotation.py @@ -7,14 +7,15 @@ from ..utils import Annotation class GridAnnotationNode(BaseNode): - RETURN_TYPES: tuple[str] = ("GRID_ANNOTATION",) + RETURN_TYPES: tuple[str, ...] = ("GRID_ANNOTATION", "INT", "INT") + RETURN_NAMES: tuple[str, ...] = ("GRID_ANNOTATION", "COLUMNS_COUNT", "ROWS_COUNT") @classmethod def INPUT_TYPES(cls) -> dict[str, t.Any]: return { "required": { - "column_texts": ("STRING", {"multiline": False}), - "row_texts": ("STRING", {"multiline": False}), + "column_texts": ("STRING", {"multiline": True}), + "row_texts": ("STRING", {"multiline": True}), "font_size": ("INT", {"default": 50, "min": 1}), }, } @@ -24,7 +25,7 @@ class GridAnnotationNode(BaseNode): column_texts: str, row_texts: str, font_size: int, - ) -> tuple[Annotation]: + ) -> tuple[Annotation, int, int]: font = ImageFont.truetype(str(STATIC_PATH / "Roboto-Regular.ttf"), size=font_size) column_texts_list = self._set_value_to_texts_list( self._get_texts_from_string(column_texts), @@ -34,11 +35,11 @@ class GridAnnotationNode(BaseNode): ) result = Annotation(column_texts=column_texts_list, row_texts=row_texts_list, font=font) - return (result,) + return (result, len(column_texts_list), len(row_texts_list)) def _get_texts_from_string(self, string: str) -> list[str]: return [ - result.replace("\\n", "\n") + result for i in string.split(";") if (result := i.strip()) != "" ] diff --git a/src/nodes/image_combine.py b/src/nodes/image_combine.py index a4c372f..1001eb3 100644 --- a/src/nodes/image_combine.py +++ b/src/nodes/image_combine.py @@ -6,7 +6,7 @@ from ..base import BaseNode class ImageCombineNode(BaseNode): - RETURN_TYPES: tuple[str] = ("IMAGE",) + RETURN_TYPES: tuple[str, ...] = ("IMAGE",) @classmethod def INPUT_TYPES(cls) -> dict[str, t.Any]: diff --git a/src/nodes/images_grid.py b/src/nodes/images_grid.py index 8081412..5406bb2 100644 --- a/src/nodes/images_grid.py +++ b/src/nodes/images_grid.py @@ -12,7 +12,7 @@ from ..utils import ( ) class BaseImagesGridNode(BaseNode): - RETURN_TYPES: tuple[str] = ("IMAGE",) + RETURN_TYPES: tuple[str, ...] = ("IMAGE",) @classmethod def _create_input_types(cls, coordinate_name: str) -> dict[str, t.Any]: diff --git a/src/nodes/latent_combine.py b/src/nodes/latent_combine.py index 6aadc40..9a004ad 100644 --- a/src/nodes/latent_combine.py +++ b/src/nodes/latent_combine.py @@ -6,7 +6,7 @@ from ..base import BaseNode class LatentCombineNode(BaseNode): - RETURN_TYPES: tuple[str] = ("LATENT",) + RETURN_TYPES: tuple[str, ...] = ("LATENT",) @classmethod def INPUT_TYPES(cls) -> dict[str, t.Any]: