updates for webui v1.6 //TODO update submodule
parent
726652f23d
commit
18cc1ade56
|
|
@ -26,11 +26,17 @@ function openoutpaint_dataURLtoFile(dataurl) {
|
|||
|
||||
async function openoutpaint_get_image_from_gallery() {
|
||||
var buttons = gradioApp().querySelectorAll(
|
||||
'[style="display: block;"].tabitem div[id$=_gallery] .thumbnail-item.thumbnail-small'
|
||||
);
|
||||
var button = gradioApp().querySelector(
|
||||
'[style="display: block;"].tabitem div[id$=_gallery] .thumbnail-item.thumbnail-small.selected'
|
||||
);
|
||||
var buttonsArray = Array.from(buttons);
|
||||
var hiddenButtons = gradioApp().querySelectorAll(
|
||||
'[style="display: none;"].tabitem div[id$=_gallery] .thumbnail-item.thumbnail-small.selected'
|
||||
);
|
||||
var hiddenButtonsArray = Array.from(hiddenButtons);
|
||||
var selectedButton = buttonsArray.filter(
|
||||
(value) => !hiddenButtonsArray.includes(value)
|
||||
);
|
||||
var button = selectedButton[0];
|
||||
|
||||
if (!button) button = buttons[0];
|
||||
|
||||
|
|
@ -270,21 +276,29 @@ const openoutpaintjs = async () => {
|
|||
});
|
||||
|
||||
// Add button to other tabs
|
||||
const createButton = () => {
|
||||
const createButton = (tabname = "default", tool = true) => {
|
||||
const button = document.createElement("button");
|
||||
button.id = "openOutpaint_tab";
|
||||
button.classList.add("lg", "secondary", "gradio-button", "svelte-1ipelgc");
|
||||
button.textContent = "Send to openOutpaint";
|
||||
button.id = tabname + "_openOutpaint_button";
|
||||
button.classList.add("lg", "secondary", "gradio-button", "svelte-1e89no8");
|
||||
button.title = "Send image to openOutpaint.";
|
||||
if (tool) {
|
||||
button.classList.add("tool");
|
||||
button.textContent = "🐠";
|
||||
} else {
|
||||
button.textContent = "Send to openOutpaint";
|
||||
}
|
||||
return button;
|
||||
};
|
||||
|
||||
const extrasBtn = createButton();
|
||||
const extrasBtn = createButton("extras");
|
||||
extrasBtn.addEventListener("click", () =>
|
||||
openoutpaint_send_gallery("WebUI Extras Resource")
|
||||
);
|
||||
gradioApp().querySelector("#tab_extras button#extras_tab").after(extrasBtn);
|
||||
gradioApp()
|
||||
.querySelector("#tab_extras button#extras_send_to_extras")
|
||||
.after(extrasBtn);
|
||||
|
||||
const pnginfoBtn = createButton();
|
||||
const pnginfoBtn = createButton("pnginfo", false);
|
||||
pnginfoBtn.addEventListener("click", () => {
|
||||
const image = gradioApp().querySelector("#pnginfo_image img");
|
||||
if (image && image.src) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import gradio as gr
|
||||
from modules import scripts
|
||||
from modules.ui_components import ToolButton
|
||||
|
||||
|
||||
class Script(scripts.Script):
|
||||
|
|
@ -11,11 +12,11 @@ class Script(scripts.Script):
|
|||
|
||||
def after_component(self, component, **kwargs):
|
||||
# Add button to both txt2img and img2img tabs
|
||||
if kwargs.get("elem_id") == "extras_tab":
|
||||
basic_send_button = gr.Button(
|
||||
"Send to openOutpaint", elem_id=f"openoutpaint_button")
|
||||
basic_send_button.click(None, [], None,
|
||||
_js="() => openoutpaint_send_gallery('WebUI Resource')")
|
||||
if kwargs.get("elem_id") == "txt2img_send_to_extras" or kwargs.get("elem_id") == "img2img_send_to_extras":
|
||||
tabname = kwargs.get("elem_id").replace("_send_to_extras", "")
|
||||
new_send_button = ToolButton('🐠', elem_id=f'{tabname}_openOutpaint_button', tooltip="Send image and prompt parameters to openOutpaint.")
|
||||
new_send_button.click(None, [], None,
|
||||
_js="() => openoutpaint_send_gallery('WebUI " + tabname + " Resource')")
|
||||
|
||||
def ui(self, is_img2img):
|
||||
return []
|
||||
|
|
|
|||
Loading…
Reference in New Issue