mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-04 03:10:21 +00:00
Fix postprocessing_enable_in_main_ui ScriptPostprocessing elem_id (#16373)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
import dataclasses
|
||||
import os
|
||||
import gradio as gr
|
||||
@@ -101,6 +102,31 @@ class ScriptPostprocessing:
|
||||
def image_changed(self):
|
||||
pass
|
||||
|
||||
tab_name = '' # used by ScriptPostprocessingForMainUI
|
||||
replace_pattern = re.compile(r'\s')
|
||||
rm_pattern = re.compile(r'[^a-z_0-9]')
|
||||
|
||||
def elem_id(self, item_id):
|
||||
"""
|
||||
Helper function to generate id for a HTML element
|
||||
constructs final id out of script name and user-supplied item_id
|
||||
'script_extras_{self.name.lower()}_{item_id}'
|
||||
{tab_name} will append to the end of the id if set
|
||||
tab_name will be set to '_img2img' or '_txt2img' if use by ScriptPostprocessingForMainUI
|
||||
|
||||
Extensions should use this function to generate element IDs
|
||||
"""
|
||||
return self.elem_id_suffix(f'extras_{self.name.lower()}_{item_id}')
|
||||
|
||||
def elem_id_suffix(self, base_id):
|
||||
"""
|
||||
Append tab_name to the base_id
|
||||
|
||||
Extensions that already have specific there element IDs and wish to keep their IDs the same when possible should use this function
|
||||
"""
|
||||
base_id = self.rm_pattern.sub('', self.replace_pattern.sub('_', base_id))
|
||||
return f'{base_id}{self.tab_name}'
|
||||
|
||||
|
||||
def wrap_call(func, filename, funcname, *args, default=None, **kwargs):
|
||||
try:
|
||||
|
Reference in New Issue
Block a user