aboutsummaryrefslogtreecommitdiffstats
path: root/modules/scripts.py
diff options
context:
space:
mode:
authorParityError <36368048+ParityError@users.noreply.github.com>2023-03-29 01:29:59 +0000
committerGitHub <noreply@github.com>2023-03-29 01:29:59 +0000
commitf69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285 (patch)
tree01852aeac922029273e08a90c683d63c6fc169cd /modules/scripts.py
parentfb68d93b6a579a424919b22682cf067ce9a8e13f (diff)
parent3856ada5cc9ac4124e20ff311ce7aa77330845d9 (diff)
downloadstable-diffusion-webui-gfx803-f69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285.tar.gz
stable-diffusion-webui-gfx803-f69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285.tar.bz2
stable-diffusion-webui-gfx803-f69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285.zip
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'modules/scripts.py')
-rw-r--r--modules/scripts.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/modules/scripts.py b/modules/scripts.py
index 8de19884..4d0bbd66 100644
--- a/modules/scripts.py
+++ b/modules/scripts.py
@@ -239,7 +239,15 @@ def load_scripts():
elif issubclass(script_class, scripts_postprocessing.ScriptPostprocessing):
postprocessing_scripts_data.append(ScriptClassData(script_class, scriptfile.path, scriptfile.basedir, module))
- for scriptfile in sorted(scripts_list):
+ def orderby(basedir):
+ # 1st webui, 2nd extensions-builtin, 3rd extensions
+ priority = {os.path.join(paths.script_path, "extensions-builtin"):1, paths.script_path:0}
+ for key in priority:
+ if basedir.startswith(key):
+ return priority[key]
+ return 9999
+
+ for scriptfile in sorted(scripts_list, key=lambda x: [orderby(x.basedir), x]):
try:
if scriptfile.basedir != paths.script_path:
sys.path = [scriptfile.basedir] + sys.path
@@ -513,6 +521,18 @@ def reload_scripts():
scripts_postproc = scripts_postprocessing.ScriptPostprocessingRunner()
+def add_classes_to_gradio_component(comp):
+ """
+ this adds gradio-* to the component for css styling (ie gradio-button to gr.Button), as well as some others
+ """
+
+ comp.elem_classes = ["gradio-" + comp.get_block_name(), *(comp.elem_classes or [])]
+
+ if getattr(comp, 'multiselect', False):
+ comp.elem_classes.append('multiselect')
+
+
+
def IOComponent_init(self, *args, **kwargs):
if scripts_current is not None:
scripts_current.before_component(self, **kwargs)
@@ -521,6 +541,8 @@ def IOComponent_init(self, *args, **kwargs):
res = original_IOComponent_init(self, *args, **kwargs)
+ add_classes_to_gradio_component(self)
+
script_callbacks.after_component_callback(self, **kwargs)
if scripts_current is not None:
@@ -531,3 +553,15 @@ def IOComponent_init(self, *args, **kwargs):
original_IOComponent_init = gr.components.IOComponent.__init__
gr.components.IOComponent.__init__ = IOComponent_init
+
+
+def BlockContext_init(self, *args, **kwargs):
+ res = original_BlockContext_init(self, *args, **kwargs)
+
+ add_classes_to_gradio_component(self)
+
+ return res
+
+
+original_BlockContext_init = gr.blocks.BlockContext.__init__
+gr.blocks.BlockContext.__init__ = BlockContext_init