feat: add "Reapply" button (#64)

* feat: add reapply button

* revert: ui rework

* chore: white space fixes

* fix: adjusted button width
This commit is contained in:
wywywywy
2023-09-17 02:57:24 +01:00
committed by GitHub
parent b80ee91168
commit b82ce634a2
2 changed files with 21 additions and 7 deletions

View File

@@ -10,8 +10,8 @@ onUiUpdate(function() {
gradioApp().querySelectorAll("#script_config_preset_cancel_save_button").forEach(el => el.setAttribute("title", "Go back"))
gradioApp().querySelectorAll("#script_config_preset_trash_button").forEach(el => el.setAttribute("title", "Permanently delete selected preset"))
gradioApp().querySelectorAll("#script_config_preset_fields_to_save > span").forEach(el => el.setAttribute("title", "Only selected field values will be saved with the preset. Unselected fields will be ignored."))
gradioApp().querySelectorAll("#script_config_preset_open_custom_tracked_components_config").forEach(el => el.setAttribute("title", "Open the config file to add new fields to the above list."))
gradioApp().querySelectorAll("#script_config_preset_open_custom_tracked_components_config").forEach(el => el.setAttribute("title", "Open the config file to add new fields to the above list."))
gradioApp().querySelectorAll("#script_config_preset_reapply_button").forEach(el => el.setAttribute("title", "Reapply the selected preset"))
})
/* No longer needed after the bump to Gradio 3.23
//this function called by config_preset_dropdown in config_presets.py

View File

@@ -1034,11 +1034,25 @@ class Script(scripts.Script):
elem_id="script_config_preset_cancel_save_button",
)
with gr.Column(scale=1, min_width=120, visible=True) as add_remove_button_column:
add_remove_button = gr.Button(
value="Add/Remove...",
elem_id="script_config_preset_add_button",
)
with gr.Column(scale=4, min_width=160, visible=True) as add_remove_button_column:
with gr.Row():
reapply_button = gr.Button(
value="\U000021A9", # ↩
elem_id="script_config_preset_reapply_button",
min_width=40,
)
components = list(component_map.values())
reapply_button.click(
fn=config_preset_dropdown_change,
inputs=[config_preset_dropdown, *components],
show_progress=False,
outputs=components,
)
add_remove_button = gr.Button(
value="Add/Remove...",
elem_id="script_config_preset_add_button",
min_width=120,
)
with gr.Row() as collapsable_row:
collapsable_row.visible = False