Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
d37cfffd
Commit
d37cfffd
authored
Oct 22, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added callback for creating new settings in extensions
parent
7fd90128
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
modules/script_callbacks.py
modules/script_callbacks.py
+11
-0
modules/shared.py
modules/shared.py
+17
-2
modules/ui.py
modules/ui.py
+5
-1
No files found.
modules/script_callbacks.py
View file @
d37cfffd
callbacks_model_loaded
=
[]
callbacks_ui_tabs
=
[]
callbacks_ui_settings
=
[]
def
clear_callbacks
():
...
...
@@ -22,6 +23,11 @@ def ui_tabs_callback():
return
res
def
ui_settings_callback
():
for
callback
in
callbacks_ui_settings
:
callback
()
def
on_model_loaded
(
callback
):
"""register a function to be called when the stable diffusion model is created; the model is
passed as an argument"""
...
...
@@ -40,3 +46,8 @@ def on_ui_tabs(callback):
"""
callbacks_ui_tabs
.
append
(
callback
)
def
on_ui_settings
(
callback
):
"""register a function to be called before UI settingsare populated; add your settings
by using shared.opts.add_option(shared.OptionInfo(...)) """
callbacks_ui_settings
.
append
(
callback
)
modules/shared.py
View file @
d37cfffd
...
...
@@ -165,13 +165,13 @@ def realesrgan_models_names():
class
OptionInfo
:
def
__init__
(
self
,
default
=
None
,
label
=
""
,
component
=
None
,
component_args
=
None
,
onchange
=
None
,
s
how_on_main_page
=
Fals
e
,
refresh
=
None
):
def
__init__
(
self
,
default
=
None
,
label
=
""
,
component
=
None
,
component_args
=
None
,
onchange
=
None
,
s
ection
=
Non
e
,
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
):
...
...
modules/ui.py
View file @
d37cfffd
...
...
@@ -1461,6 +1461,9 @@ def create_ui(wrap_gradio_gpu_call):
components
=
[]
component_dict
=
{}
script_callbacks
.
ui_settings_callback
()
opts
.
reorder
()
def
open_folder
(
f
):
if
not
os
.
path
.
exists
(
f
):
print
(
f
'Folder "{f}" does not exist. After you create an image, the folder will be created.'
)
...
...
@@ -1564,7 +1567,8 @@ Requested path was: {f}
previous_section
=
item
.
section
gr
.
HTML
(
elem_id
=
"settings_header_text_{}"
.
format
(
item
.
section
[
0
]),
value
=
'<h1 class="gr-button-lg">{}</h1>'
.
format
(
item
.
section
[
1
]))
elem_id
,
text
=
item
.
section
gr
.
HTML
(
elem_id
=
"settings_header_text_{}"
.
format
(
elem_id
),
value
=
'<h1 class="gr-button-lg">{}</h1>'
.
format
(
text
))
if
k
in
quicksettings_names
:
quicksettings_list
.
append
((
i
,
k
,
item
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment