From 1f140749d4ccb4136d7af3bf546c21688e878df6 Mon Sep 17 00:00:00 2001 From: Will Cole <48973146+wcole3@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:47:09 -0500 Subject: [PATCH] Add source_text_component to Results paste buttons (#2349) * Add source_text_component to Results paste buttons * Cleanup' 'Extras tab' case paste elements --- modules/ui_common.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/ui_common.py b/modules/ui_common.py index 58c4e27e..51811578 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -15,17 +15,16 @@ import modules.infotext_utils as parameters_copypaste folder_symbol = '\U0001f4c2' # 📂 refresh_symbol = '\U0001f504' # 🔄 - def update_generation_info(generation_info, html_info, img_index): try: generation_info = json.loads(generation_info) if img_index < 0 or img_index >= len(generation_info["infotexts"]): - return html_info, gr.update() - return plaintext_to_html(generation_info["infotexts"][img_index]), gr.update() + return html_info, gr.update(), html_info + return plaintext_to_html(generation_info["infotexts"][img_index]), gr.update(), generation_info["infotexts"][img_index] except Exception: pass # if the json parse or anything else fails, just return the old html_info - return html_info, gr.update() + return html_info, gr.update(), html_info def plaintext_to_html(text, classname=None): @@ -154,6 +153,7 @@ class OutputPanel: gallery = None generation_info = None infotext = None + infotext_plaintext = None html_log = None button_upscale = None @@ -217,13 +217,14 @@ def create_output_panel(tabname, outdir, toprow=None): res.html_log = gr.HTML(elem_id=f'html_log_{tabname}', elem_classes="html-log") res.generation_info = gr.Textbox(visible=False, elem_id=f'generation_info_{tabname}') + res.infotext_plaintext = gr.Textbox(visible=False, elem_id=f'infotext_plaintext_{tabname}') if tabname == 'txt2img' or tabname == 'img2img': generation_info_button = gr.Button(visible=False, elem_id=f"{tabname}_generation_info_button") generation_info_button.click( fn=update_generation_info, _js="function(x, y, z){ return [x, y, selected_gallery_index()] }", inputs=[res.generation_info, res.infotext, res.infotext], - outputs=[res.infotext, res.infotext], + outputs=[res.infotext, res.infotext, res.infotext_plaintext], show_progress=False, ) @@ -261,7 +262,8 @@ def create_output_panel(tabname, outdir, toprow=None): else: res.generation_info = gr.HTML(elem_id=f'html_info_x_{tabname}') res.infotext = gr.HTML(elem_id=f'html_info_{tabname}', elem_classes="infotext") - res.html_log = gr.HTML(elem_id=f'html_log_{tabname}') + res.infotext_plaintext = gr.HTML(visible=False, elem_id=f'infotext_plaintext_{tabname}', elem_classes="infotext") + res.html_log = gr.HTML(elem_id=f'html_log_{tabname}', elem_classes="html-log") paste_field_names = [] if tabname == "txt2img": @@ -271,7 +273,7 @@ def create_output_panel(tabname, outdir, toprow=None): for paste_tabname, paste_button in buttons.items(): parameters_copypaste.register_paste_params_button(parameters_copypaste.ParamBinding( - paste_button=paste_button, tabname=paste_tabname, source_tabname="txt2img" if tabname == "txt2img" else None, source_image_component=res.gallery, + paste_button=paste_button, tabname=paste_tabname, source_tabname="txt2img" if tabname == "txt2img" else None, source_text_component=res.infotext_plaintext, source_image_component=res.gallery, paste_field_names=paste_field_names ))