Add section splitting to settings ui
This commit is contained in:
parent
dec7584903
commit
6d1c01c955
1 changed files with 16 additions and 7 deletions
|
@ -9,6 +9,7 @@ import random
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
import itertools
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
|
@ -842,14 +843,22 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||||
settings_submit = gr.Button(value="Apply settings", variant='primary')
|
settings_submit = gr.Button(value="Apply settings", variant='primary')
|
||||||
result = gr.HTML()
|
result = gr.HTML()
|
||||||
|
|
||||||
with gr.Row(elem_id="settings").style(equal_height=False):
|
sortedKeys = sorted([(opts.data_labels[key].section,key) for key in keys],key=lambda x:x[0])
|
||||||
for colno in range(settings_cols):
|
groupedKeys = itertools.groupby(sortedKeys,key=lambda x:x[0])
|
||||||
with gr.Column(variant='panel'):
|
|
||||||
for rowno in range(items_per_col):
|
|
||||||
index = rowno + colno * items_per_col
|
|
||||||
|
|
||||||
if index < len(keys):
|
for (sectionNumber,sectionName),sectionGroup in groupedKeys:
|
||||||
components.append(create_setting_component(keys[index]))
|
with gr.Row(elem_id="settings_header_{}".format(sectionNumber)).style(equal_height=False):
|
||||||
|
gr.HTML(elem_id="settings_header_text_{}".format(sectionNumber), value='<h1 class="gr-button-lg">{}</h1>'.format(sectionName))
|
||||||
|
|
||||||
|
with gr.Row(elem_id="settings_{}".format(sectionNumber)).style(equal_height=False):
|
||||||
|
columnLookup = {}
|
||||||
|
for colNum,element in zip(itertools.cycle(range(settings_cols)),sectionGroup):
|
||||||
|
columnLookup.setdefault(colNum,[]).append(element)
|
||||||
|
|
||||||
|
for colno,elements in sorted(columnLookup.items()):
|
||||||
|
with gr.Column(variant='panel'):
|
||||||
|
for _,keyElement in elements:
|
||||||
|
components.append(create_setting_component(keyElement))
|
||||||
|
|
||||||
settings_submit.click(
|
settings_submit.click(
|
||||||
fn=run_settings,
|
fn=run_settings,
|
||||||
|
|
Loading…
Reference in a new issue