From 4dd898b8c15e342f817d3fb1c8dc9f2d5d111022 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 4 Nov 2022 08:38:11 +0300 Subject: do not mess with components' visibility for scripts; instead create group components and show/hide those; this will break scripts that create invisible components and rely on UI but the earlier i make this change the better --- scripts/custom_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/custom_code.py') diff --git a/scripts/custom_code.py b/scripts/custom_code.py index a9b10c09..22e7b77a 100644 --- a/scripts/custom_code.py +++ b/scripts/custom_code.py @@ -14,7 +14,7 @@ class Script(scripts.Script): return cmd_opts.allow_code def ui(self, is_img2img): - code = gr.Textbox(label="Python code", visible=False, lines=1) + code = gr.Textbox(label="Python code", lines=1) return [code] -- cgit v1.2.3 From 5851bc839b6f639cda59e84eb1ee8c706986633d Mon Sep 17 00:00:00 2001 From: me <25877290+Kryptortio@users.noreply.github.com> Date: Wed, 4 Jan 2023 22:03:32 +0100 Subject: Add element ids for script components and a few more in ui.py --- scripts/custom_code.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/custom_code.py') diff --git a/scripts/custom_code.py b/scripts/custom_code.py index 22e7b77a..841fed97 100644 --- a/scripts/custom_code.py +++ b/scripts/custom_code.py @@ -14,7 +14,9 @@ class Script(scripts.Script): return cmd_opts.allow_code def ui(self, is_img2img): - code = gr.Textbox(label="Python code", lines=1) + elem_prefix = ('i2i' if is_img2img else 't2i') + '_script_custom_code_' + + code = gr.Textbox(label="Python code", lines=1, elem_id=elem_prefix + "code") return [code] -- cgit v1.2.3 From c3109fa18a5a105eea5e343875b540939884f304 Mon Sep 17 00:00:00 2001 From: me <25877290+Kryptortio@users.noreply.github.com> Date: Thu, 5 Jan 2023 08:27:09 +0100 Subject: Adjusted prefix from i2i/t2i to txt2img and img2img and removed those prefixes from img exclusive scripts --- scripts/custom_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/custom_code.py') diff --git a/scripts/custom_code.py b/scripts/custom_code.py index 841fed97..b3bbee03 100644 --- a/scripts/custom_code.py +++ b/scripts/custom_code.py @@ -14,7 +14,7 @@ class Script(scripts.Script): return cmd_opts.allow_code def ui(self, is_img2img): - elem_prefix = ('i2i' if is_img2img else 't2i') + '_script_custom_code_' + elem_prefix = ('img2img' if is_img2img else 'txt2txt') + '_script_custom_code_' code = gr.Textbox(label="Python code", lines=1, elem_id=elem_prefix + "code") -- cgit v1.2.3 From f185baeb28f348e4ec97cd7070ed219b5f74a48e Mon Sep 17 00:00:00 2001 From: me <25877290+Kryptortio@users.noreply.github.com> Date: Thu, 5 Jan 2023 09:29:07 +0100 Subject: Refactor elem_prefix as function elem_id --- scripts/custom_code.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts/custom_code.py') diff --git a/scripts/custom_code.py b/scripts/custom_code.py index b3bbee03..9ce1f650 100644 --- a/scripts/custom_code.py +++ b/scripts/custom_code.py @@ -3,20 +3,23 @@ import gradio as gr from modules.processing import Processed from modules.shared import opts, cmd_opts, state +import re class Script(scripts.Script): def title(self): return "Custom code" + def elem_id(self, item_id): + gen_elem_id = ('img2img' if self.is_img2img else 'txt2txt') + '_script_' + re.sub(r'\s', '_', self.title().lower()) + '_' + item_id + gen_elem_id = re.sub(r'[^a-z_0-9]', '', gen_elem_id) + return gen_elem_id def show(self, is_img2img): return cmd_opts.allow_code def ui(self, is_img2img): - elem_prefix = ('img2img' if is_img2img else 'txt2txt') + '_script_custom_code_' - - code = gr.Textbox(label="Python code", lines=1, elem_id=elem_prefix + "code") + code = gr.Textbox(label="Python code", lines=1, elem_id=self.elem_id("code")) return [code] -- cgit v1.2.3 From f8d0cf6a6ec4911559cfecb9a9d1d46b547b38e8 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 5 Jan 2023 12:08:11 +0300 Subject: rework #6329 to remove duplicate code and add prevent tab names for showing in ids for scripts that only exist on one tab --- scripts/custom_code.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'scripts/custom_code.py') diff --git a/scripts/custom_code.py b/scripts/custom_code.py index 9ce1f650..d29113e6 100644 --- a/scripts/custom_code.py +++ b/scripts/custom_code.py @@ -3,18 +3,12 @@ import gradio as gr from modules.processing import Processed from modules.shared import opts, cmd_opts, state -import re class Script(scripts.Script): def title(self): return "Custom code" - def elem_id(self, item_id): - gen_elem_id = ('img2img' if self.is_img2img else 'txt2txt') + '_script_' + re.sub(r'\s', '_', self.title().lower()) + '_' + item_id - gen_elem_id = re.sub(r'[^a-z_0-9]', '', gen_elem_id) - return gen_elem_id - def show(self, is_img2img): return cmd_opts.allow_code -- cgit v1.2.3