aboutsummaryrefslogtreecommitdiff
path: root/modules/ui_common.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-03 22:46:57 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2023-08-03 23:31:13 +0300
commit20549a50cb3c41868ce561c6658bfaa0d20ac7ba (patch)
tree789d872fc05f12633125c37c0ce88f6a4df8e597 /modules/ui_common.py
parent8e840e151917892af8d8681781b231a1fc47d404 (diff)
add style editor dialog
rework toprow for img2img and txt2img to use a class with fields fix the console error when editing checkpoint user metadata
Diffstat (limited to 'modules/ui_common.py')
-rw-r--r--modules/ui_common.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/modules/ui_common.py b/modules/ui_common.py
index 11eb2a4b..ba75fa73 100644
--- a/modules/ui_common.py
+++ b/modules/ui_common.py
@@ -223,20 +223,44 @@ Requested path was: {f}
def create_refresh_button(refresh_component, refresh_method, refreshed_args, elem_id):
+ refresh_components = refresh_component if isinstance(refresh_component, list) else [refresh_component]
+
+ label = None
+ for comp in refresh_components:
+ label = getattr(comp, 'label', None)
+ if label is not None:
+ break
+
def refresh():
refresh_method()
args = refreshed_args() if callable(refreshed_args) else refreshed_args
for k, v in args.items():
- setattr(refresh_component, k, v)
+ for comp in refresh_components:
+ setattr(comp, k, v)
- return gr.update(**(args or {}))
+ return [gr.update(**(args or {})) for _ in refresh_components]
- refresh_button = ToolButton(value=refresh_symbol, elem_id=elem_id)
+ refresh_button = ToolButton(value=refresh_symbol, elem_id=elem_id, tooltip=f"{label}: refresh" if label else "Refresh")
refresh_button.click(
fn=refresh,
inputs=[],
- outputs=[refresh_component]
+ outputs=[*refresh_components]
)
return refresh_button
+
+def setup_dialog(button_show, dialog, *, button_close=None):
+ """Sets up the UI so that the dialog (gr.Box) is invisible, and is only shown when buttons_show is clicked, in a fullscreen modal window."""
+
+ dialog.visible = False
+
+ button_show.click(
+ fn=lambda: gr.update(visible=True),
+ inputs=[],
+ outputs=[dialog],
+ ).then(fn=None, _js="function(){ popup(gradioApp().getElementById('" + dialog.elem_id + "')); }")
+
+ if button_close:
+ button_close.click(fn=None, _js="closePopup")
+