diff options
author | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-08-08 02:39:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 02:39:34 +0000 |
commit | f17c8c2eff63210f5e96e1e2b049b46ba9cfa389 (patch) | |
tree | 701056aec9ae11bc45df9b39b176a54fa4d34e19 /modules/ui_common.py | |
parent | c75bda867be5345bf959daf23bdc19eadc90841a (diff) | |
parent | 01997f45ba089af24b03a5f614147bb0f9d8d824 (diff) | |
download | stable-diffusion-webui-gfx803-f17c8c2eff63210f5e96e1e2b049b46ba9cfa389.tar.gz stable-diffusion-webui-gfx803-f17c8c2eff63210f5e96e1e2b049b46ba9cfa389.tar.bz2 stable-diffusion-webui-gfx803-f17c8c2eff63210f5e96e1e2b049b46ba9cfa389.zip |
Merge branch 'dev' into auro-autolaunch
Diffstat (limited to 'modules/ui_common.py')
-rw-r--r-- | modules/ui_common.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/modules/ui_common.py b/modules/ui_common.py index 11eb2a4b..303af9cd 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -134,7 +134,7 @@ Requested path was: {f} with gr.Column(variant='panel', elem_id=f"{tabname}_results"):
with gr.Group(elem_id=f"{tabname}_gallery_container"):
- result_gallery = gr.Gallery(label='Output', show_label=False, elem_id=f"{tabname}_gallery").style(columns=4)
+ result_gallery = gr.Gallery(label='Output', show_label=False, elem_id=f"{tabname}_gallery", columns=4)
generation_info = None
with gr.Column():
@@ -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] if len(refresh_components) > 1 else gr.update(**(args or {}))
- 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")
+
|