This commit is contained in:
Thomas Mello 2022-08-30 22:18:29 +03:00 committed by hlky
parent 3ce28c2e76
commit 3a376392b3
3 changed files with 22 additions and 1 deletions

View File

@ -33,3 +33,5 @@ def js_copy_to_clipboard(from_id):
def js_painterro_launch(to_id): def js_painterro_launch(to_id):
return w(f"Painterro.init('{to_id}')") return w(f"Painterro.init('{to_id}')")
def js_img2img_submit(prompt_row_id):
return w(f"clickFirstVisibleButton('{prompt_row_id}')")

View File

@ -280,7 +280,10 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, txt2img_defaul
img2img_embeddings], img2img_embeddings],
[output_img2img_gallery, output_img2img_seed, output_img2img_params, output_img2img_stats]) [output_img2img_gallery, output_img2img_seed, output_img2img_params, output_img2img_stats])
img2img_btn_editor.click(*img2img_submit_params()) img2img_btn_editor.click(*img2img_submit_params())
img2img_prompt.submit(*img2img_submit_params())
# GENERATE ON ENTER
img2img_prompt.submit(None, None, None,
_js=js_img2img_submit("prompt_row"))
img2img_painterro_btn.click(None, [img2img_image_editor], [img2img_image_editor, img2img_image_mask], _js=js_painterro_launch('img2img_editor')) img2img_painterro_btn.click(None, [img2img_image_editor], [img2img_image_editor, img2img_image_mask], _js=js_painterro_launch('img2img_editor'))

View File

@ -131,6 +131,22 @@ window.SD = (() => {
clearImageInput (imageEditor) { clearImageInput (imageEditor) {
imageEditor?.querySelector('.modify-upload button:last-child')?.click(); imageEditor?.querySelector('.modify-upload button:last-child')?.click();
} }
clickFirstVisibleButton(rowId) {
const generateButtons = this.el.get(`#${rowId}`).querySelectorAll('.gr-button-primary');
if (!generateButtons) return;
for (let i = 0, arr = [...generateButtons]; i < arr.length; i++) {
const cs = window.getComputedStyle(arr[i]);
if (cs.display !== 'none' && cs.visibility !== 'hidden') {
console.log(arr[i]);
arr[i].click();
break;
}
}
}
static error (e) { static error (e) {
console.error(e); console.error(e);
if (typeof e === 'string') { if (typeof e === 'string') {