aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ui_prompt_styles.py
diff options
context:
space:
mode:
authorw-e-w <40751091+w-e-w@users.noreply.github.com>2024-01-20 17:21:36 +0000
committerw-e-w <40751091+w-e-w@users.noreply.github.com>2024-01-20 18:53:58 +0000
commit25e8273d2f6481deca221b29d35093f6d0c9da6a (patch)
tree8aa4651858aa851811341778a3e41092aab46f61 /modules/ui_prompt_styles.py
parentf939bce845ae07536b1c920618743af83e0b01ec (diff)
downloadstable-diffusion-webui-gfx803-25e8273d2f6481deca221b29d35093f6d0c9da6a.tar.gz
stable-diffusion-webui-gfx803-25e8273d2f6481deca221b29d35093f6d0c9da6a.tar.bz2
stable-diffusion-webui-gfx803-25e8273d2f6481deca221b29d35093f6d0c9da6a.zip
re-work multi --styles-file
--styles-file change to append str --styles-file is [] then defaults to [styles.csv] --styles-file accepts paths or paths with wildcard "*" the first `--styles-file` entry is use as the default styles file path if filename a wildcard then the first matching file is used if no match is found, create a new "styles.csv" in the same dir as the first path when saving a new style it will be save in the default styles file when saving a existing style, it will be saved to file it belongs to order of the styles files in the styles dropdown can be controlled to a certain degree by the order of --styles-file
Diffstat (limited to 'modules/ui_prompt_styles.py')
-rw-r--r--modules/ui_prompt_styles.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/ui_prompt_styles.py b/modules/ui_prompt_styles.py
index 0d74c23f..d67e3f17 100644
--- a/modules/ui_prompt_styles.py
+++ b/modules/ui_prompt_styles.py
@@ -22,9 +22,12 @@ def save_style(name, prompt, negative_prompt):
if not name:
return gr.update(visible=False)
- style = styles.PromptStyle(name, prompt, negative_prompt)
+ existing_style = shared.prompt_styles.styles.get(name)
+ path = existing_style.path if existing_style is not None else None
+
+ style = styles.PromptStyle(name, prompt, negative_prompt, path)
shared.prompt_styles.styles[style.name] = style
- shared.prompt_styles.save_styles(shared.styles_filename)
+ shared.prompt_styles.save_styles()
return gr.update(visible=True)
@@ -34,7 +37,7 @@ def delete_style(name):
return
shared.prompt_styles.styles.pop(name, None)
- shared.prompt_styles.save_styles(shared.styles_filename)
+ shared.prompt_styles.save_styles()
return '', '', ''