diff options
author | pieresimakp <69743585+pieresimakp@users.noreply.github.com> | 2023-03-25 23:00:45 +0800 |
---|---|---|
committer | pieresimakp <69743585+pieresimakp@users.noreply.github.com> | 2023-03-25 23:00:45 +0800 |
commit | e3b9d0e3e8adfb6214a1eb7acf450574f427ff9d (patch) | |
tree | c9c64ad1f926df990fb2ce05c6eec063de195eec /modules/scripts.py | |
parent | 771ea212de13711b494b082d8e94e79b17ac9d08 (diff) | |
parent | 91ae48fd7e20c60d6374f340cac0939f56d87048 (diff) |
Merge branch 'master' into img2img-detect-image-size
Diffstat (limited to 'modules/scripts.py')
-rw-r--r-- | modules/scripts.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/modules/scripts.py b/modules/scripts.py index 8de19884..d661be4f 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:
|