diff options
author | space-nuko <24979496+space-nuko@users.noreply.github.com> | 2023-03-27 21:26:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 21:26:23 +0000 |
commit | 082613036aa7b9a8a008384b1770046d6714bc28 (patch) | |
tree | a14ceb8cc54e7359058376ff6eb05bc3471f5e67 /modules/scripts.py | |
parent | d86beb822832c9162714cf0a3567ad087839a2ac (diff) | |
parent | 955df7751eef11bb7697e2d77f6b8a6226b21e13 (diff) | |
download | stable-diffusion-webui-gfx803-082613036aa7b9a8a008384b1770046d6714bc28.tar.gz stable-diffusion-webui-gfx803-082613036aa7b9a8a008384b1770046d6714bc28.tar.bz2 stable-diffusion-webui-gfx803-082613036aa7b9a8a008384b1770046d6714bc28.zip |
Merge branch 'master' into remove-watermark-option
Diffstat (limited to 'modules/scripts.py')
-rw-r--r-- | modules/scripts.py | 36 |
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
|