diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-01-05 11:56:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 11:56:13 +0300 |
commit | 01a1fee874e12eb68d849a31bbf177c69ff4cc22 (patch) | |
tree | eeae4ceb55386c0f4debc614586c2fddb16372f2 /scripts/custom_code.py | |
parent | 42fcc79bd31e5e5485f1cf115ad505cc623d0ac9 (diff) | |
parent | f185baeb28f348e4ec97cd7070ed219b5f74a48e (diff) |
Merge pull request #6329 from Kryptortio/add_even_more_element_ids
Add additional elem_id/HTML ids (again)
Diffstat (limited to 'scripts/custom_code.py')
-rw-r--r-- | scripts/custom_code.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scripts/custom_code.py b/scripts/custom_code.py index 22e7b77a..9ce1f650 100644 --- a/scripts/custom_code.py +++ b/scripts/custom_code.py @@ -3,18 +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):
- code = gr.Textbox(label="Python code", lines=1)
+ code = gr.Textbox(label="Python code", lines=1, elem_id=self.elem_id("code"))
return [code]
|