diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-10-22 16:18:56 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-10-22 16:18:56 +0000 |
commit | d37cfffd537cd29309afbcb192c4f979995c6a34 (patch) | |
tree | 054c2cbb701f8060549600e81fa77e8cfa115d70 /modules/shared.py | |
parent | 7fd90128eb6d1820045bfe2c2c1269661023a712 (diff) | |
download | stable-diffusion-webui-gfx803-d37cfffd537cd29309afbcb192c4f979995c6a34.tar.gz stable-diffusion-webui-gfx803-d37cfffd537cd29309afbcb192c4f979995c6a34.tar.bz2 stable-diffusion-webui-gfx803-d37cfffd537cd29309afbcb192c4f979995c6a34.zip |
added callback for creating new settings in extensions
Diffstat (limited to 'modules/shared.py')
-rw-r--r-- | modules/shared.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/modules/shared.py b/modules/shared.py index 5d83971e..d9cb65ef 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -165,13 +165,13 @@ def realesrgan_models_names(): class OptionInfo:
- def __init__(self, default=None, label="", component=None, component_args=None, onchange=None, show_on_main_page=False, refresh=None):
+ def __init__(self, default=None, label="", component=None, component_args=None, onchange=None, section=None, refresh=None):
self.default = default
self.label = label
self.component = component
self.component_args = component_args
self.onchange = onchange
- self.section = None
+ self.section = section
self.refresh = refresh
@@ -327,6 +327,7 @@ options_templates.update(options_section(('images-history', "Images Browser"), { }))
+
class Options:
data = None
data_labels = options_templates
@@ -389,6 +390,20 @@ class Options: d = {k: self.data.get(k, self.data_labels.get(k).default) for k in self.data_labels.keys()}
return json.dumps(d)
+ def add_option(self, key, info):
+ self.data_labels[key] = info
+
+ def reorder(self):
+ """reorder settings so that all items related to section always go together"""
+
+ section_ids = {}
+ settings_items = self.data_labels.items()
+ for k, item in settings_items:
+ if item.section not in section_ids:
+ section_ids[item.section] = len(section_ids)
+
+ self.data_labels = {k: v for k, v in sorted(settings_items, key=lambda x: section_ids[x[1].section])}
+
opts = Options()
if os.path.exists(config_filename):
|