feat: change title of aspect ratios accordion on load and update

This commit is contained in:
Manuel Schmid 2024-05-26 16:09:23 +02:00
parent a0114de9e9
commit 011f65ba78
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
1 changed files with 17 additions and 3 deletions

View File

@ -266,11 +266,25 @@ with shared.gradio_root:
choices=flags.Performance.list(),
value=modules.config.default_performance,
elem_classes=['performance_selection'])
with gr.Accordion('Resolution', open=False):
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios,
value=modules.config.default_aspect_ratio, info='width × height',
with gr.Accordion(label='Aspect Ratios', open=False) as aspect_ratios_accordion:
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', show_label=False,
choices=modules.config.available_aspect_ratios,
value=modules.config.default_aspect_ratio,
info='width × height',
elem_classes='aspect_ratios')
def change_aspect_ratio(text):
import re
regex = re.compile('<.*?>')
cleaned_text = re.sub(regex, '', text)
return gr.update(label='Aspect Ratios ' + cleaned_text)
aspect_ratios_selection.change(change_aspect_ratio, inputs=aspect_ratios_selection,
outputs=aspect_ratios_accordion, show_progress=False, queue=False)
shared.gradio_root.load(change_aspect_ratio, inputs=aspect_ratios_selection,
outputs=aspect_ratios_accordion, queue=False, show_progress=False)
output_format = gr.Radio(label='Output Format',
choices=flags.OutputFormat.list(),
value=modules.config.default_output_format)