From 960e93079defe6a3b2b17fa3b9c0203d727dc67c Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Sat, 27 Apr 2024 21:36:10 -0400 Subject: [PATCH] Use A1111's ToolButton impl (#2820) * Use A1111's ToolButton impl * Use FormHTML --- scripts/controlnet_ui/controlnet_ui_group.py | 5 ++--- scripts/controlnet_ui/preset.py | 2 +- scripts/controlnet_ui/tool_button.py | 12 ------------ 3 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 scripts/controlnet_ui/tool_button.py diff --git a/scripts/controlnet_ui/controlnet_ui_group.py b/scripts/controlnet_ui/controlnet_ui_group.py index d7a003804..2bfc18e22 100644 --- a/scripts/controlnet_ui/controlnet_ui_group.py +++ b/scripts/controlnet_ui/controlnet_ui_group.py @@ -16,12 +16,11 @@ from scripts.logging import logger from scripts.controlnet_ui.openpose_editor import OpenposeEditor from scripts.controlnet_ui.preset import ControlNetPresetUI -from scripts.controlnet_ui.tool_button import ToolButton from scripts.controlnet_ui.photopea import Photopea from scripts.controlnet_ui.advanced_weight_control import AdvancedWeightControl from scripts.enums import InputMode from modules import shared -from modules.ui_components import FormRow +from modules.ui_components import FormRow, FormHTML, ToolButton @dataclass @@ -430,7 +429,7 @@ def render(self, tabname: str, elem_id_tabname: str) -> None: ) with gr.Row(elem_classes="controlnet_image_controls"): - gr.HTML( + FormHTML( value="

Set the preprocessor to [invert] If your image has white background and black lines.

", elem_classes="controlnet_invert_warning", ) diff --git a/scripts/controlnet_ui/preset.py b/scripts/controlnet_ui/preset.py index 89ecb732b..3010d2617 100644 --- a/scripts/controlnet_ui/preset.py +++ b/scripts/controlnet_ui/preset.py @@ -4,8 +4,8 @@ from typing import Dict, List from modules import scripts +from modules.ui_components import ToolButton from scripts.infotext import parse_unit, serialize_unit -from scripts.controlnet_ui.tool_button import ToolButton from scripts.logging import logger from scripts import external_code from scripts.supported_preprocessor import Preprocessor diff --git a/scripts/controlnet_ui/tool_button.py b/scripts/controlnet_ui/tool_button.py deleted file mode 100644 index 8a38df8f4..000000000 --- a/scripts/controlnet_ui/tool_button.py +++ /dev/null @@ -1,12 +0,0 @@ -import gradio as gr - -class ToolButton(gr.Button, gr.components.FormComponent): - """Small button with single emoji as text, fits inside gradio forms""" - - def __init__(self, **kwargs): - super().__init__(variant="tool", - elem_classes=kwargs.pop('elem_classes', []) + ["cnet-toolbutton"], - **kwargs) - - def get_block_name(self): - return "button"