mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-04 03:10:21 +00:00
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
This commit is contained in:
@@ -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 '', '', ''
|
||||
|
||||
|
Reference in New Issue
Block a user