aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ui.py
diff options
context:
space:
mode:
authorふぁ <34892635+fa0311@users.noreply.github.com>2022-10-18 09:51:57 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-18 12:08:23 +0000
commit3003438088502774628656790d83fc8074d51ab4 (patch)
tree281d2f134c8ff061746210afc4727ce896a7967d /modules/ui.py
parentde29ec0743fcfb141d8891a3ccbd537ea71bf5b4 (diff)
downloadstable-diffusion-webui-gfx803-3003438088502774628656790d83fc8074d51ab4.tar.gz
stable-diffusion-webui-gfx803-3003438088502774628656790d83fc8074d51ab4.tar.bz2
stable-diffusion-webui-gfx803-3003438088502774628656790d83fc8074d51ab4.zip
Add visible for dropdown
Diffstat (limited to 'modules/ui.py')
-rw-r--r--modules/ui.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/ui.py b/modules/ui.py
index b38bfb3f..fb6eb5a0 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1737,7 +1737,7 @@ Requested path was: {f}
print(traceback.format_exc(), file=sys.stderr)
def loadsave(path, x):
- def apply_field(obj, field, condition=None):
+ def apply_field(obj, field, condition=None, init_field=None):
key = path + "/" + field
if getattr(obj,'custom_script_source',None) is not None:
@@ -1753,8 +1753,8 @@ Requested path was: {f}
print(f'Warning: Bad ui setting value: {key}: {saved_value}; Default value "{getattr(obj, field)}" will be used instead.')
else:
setattr(obj, field, saved_value)
- if getattr(x, 'init_field', False):
- x.init_field(saved_value)
+ if init_field is not None:
+ init_field(saved_value)
if type(x) in [gr.Slider, gr.Radio, gr.Checkbox, gr.Textbox, gr.Number] and x.visible:
apply_field(x, 'visible')
@@ -1780,7 +1780,8 @@ Requested path was: {f}
# Since there are many dropdowns that shouldn't be saved,
# we only mark dropdowns that should be saved.
if type(x) == gr.Dropdown and getattr(x, 'save_to_config', False):
- apply_field(x, 'value', lambda val: val in x.choices)
+ apply_field(x, 'value', lambda val: val in x.choices, getattr(x, 'init_field', None))
+ apply_field(x, 'visible')
visit(txt2img_interface, loadsave, "txt2img")
visit(img2img_interface, loadsave, "img2img")