mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
add on_after_ui callback
This commit is contained in:
@@ -123,6 +123,7 @@ callback_map = dict(
|
||||
callbacks_infotext_pasted=[],
|
||||
callbacks_script_unloaded=[],
|
||||
callbacks_before_ui=[],
|
||||
callbacks_after_ui=[],
|
||||
callbacks_on_reload=[],
|
||||
)
|
||||
|
||||
@@ -359,6 +360,16 @@ def before_ui_callback():
|
||||
report_exception(e, c, 'before_ui')
|
||||
|
||||
|
||||
def after_ui_callback():
|
||||
for c in reversed(callback_map['callbacks_after_ui']):
|
||||
try:
|
||||
t0 = time.time()
|
||||
c.callback()
|
||||
timer(t0, c.script, 'after_ui')
|
||||
except Exception as e:
|
||||
report_exception(e, c, 'after_ui')
|
||||
|
||||
|
||||
def add_callback(callbacks, fun):
|
||||
# stack = [x for x in inspect.stack(0) if x.filename != __file__]
|
||||
# filename = stack[0].filename if len(stack) > 0 else 'unknown file'
|
||||
@@ -536,3 +547,8 @@ def on_script_unloaded(callback):
|
||||
def on_before_ui(callback):
|
||||
"""register a function to be called before the UI is created."""
|
||||
add_callback(callback_map['callbacks_before_ui'], callback)
|
||||
|
||||
|
||||
def on_after_ui(callback):
|
||||
"""register a function to be called before the UI is created."""
|
||||
add_callback(callback_map['callbacks_after_ui'], callback)
|
||||
|
||||
@@ -405,6 +405,7 @@ def create_ui(startup_timer = None):
|
||||
loadsave.add_block(interface, ifid)
|
||||
loadsave.add_component(f"webui/Tabs@{tabs.elem_id}", tabs)
|
||||
loadsave.setup_ui()
|
||||
|
||||
if opts.notification_audio_enable and os.path.exists(os.path.join(script_path, opts.notification_audio_path)):
|
||||
gr.Audio(interactive=False, value=os.path.join(script_path, opts.notification_audio_path), elem_id="audio_notification", visible=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user