From d3f9156854b3d6b4c3d5d736f3b0454743203076 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sat, 18 Nov 2023 13:02:39 +0100 Subject: [PATCH] only make stop_button and skip_button interactive when rendering process starts fix inconsistency in behaviour of stop_button and skip_button as it was possible to skip or stop other users processes while still being in queue --- webui.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/webui.py b/webui.py index d1381d5e..35ef0629 100644 --- a/webui.py +++ b/webui.py @@ -31,7 +31,9 @@ def generate_clicked(*args): yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Waiting for task to start ...')), \ gr.update(visible=True, value=None), \ gr.update(visible=False, value=None), \ - gr.update(visible=False) + gr.update(visible=False), \ + gr.update(visible=True, interactive=True), \ + gr.update(visible=True, interactive=True) worker.async_tasks.append(task) @@ -51,17 +53,23 @@ def generate_clicked(*args): yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \ gr.update(visible=True, value=image) if image is not None else gr.update(), \ gr.update(), \ - gr.update(visible=False) + gr.update(visible=False), \ + gr.update(visible=True), \ + gr.update(visible=True) if flag == 'results': yield gr.update(visible=True), \ gr.update(visible=True), \ gr.update(visible=True, value=product), \ - gr.update(visible=False) + gr.update(visible=False), \ + gr.update(visible=True), \ + gr.update(visible=True) if flag == 'finish': yield gr.update(visible=False), \ gr.update(visible=False), \ gr.update(visible=False), \ - gr.update(visible=True, value=product) + gr.update(visible=True, value=product), \ + gr.update(visible=False), \ + gr.update(visible=False) finished = True execution_time = time.perf_counter() - execution_start_time @@ -437,10 +445,10 @@ with shared.gradio_root: ctrls += [outpaint_selections, inpaint_input_image] ctrls += ip_ctrls - generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False), []), outputs=[stop_button, skip_button, generate_button, gallery]) \ + generate_button.click(lambda: (gr.update(visible=True, interactive=False), gr.update(visible=True, interactive=False), gr.update(visible=False), []), outputs=[stop_button, skip_button, generate_button, gallery]) \ .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \ .then(advanced_parameters.set_all_advanced_parameters, inputs=adps) \ - .then(fn=generate_clicked, inputs=ctrls, outputs=[progress_html, progress_window, progress_gallery, gallery]) \ + .then(fn=generate_clicked, inputs=ctrls, outputs=[progress_html, progress_window, progress_gallery, gallery, stop_button, skip_button]) \ .then(lambda: (gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)), outputs=[generate_button, stop_button, skip_button]) \ .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')