-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move extension to the top of the list #4
Comments
Do you want it at the top of the list, or do you want it to not display in the list? |
Try this. In the root of your application, the folder that has your readme and script folder, create a sd-webui-ar
├── .gitignore
├── README.md
├── aspect_ratios.txt
├── resolutions.txt
├── style.css
└── scripts
└── sd-webui-ar.py In style.css, paste this: #script_list option[value^="Aspect Ratio picker"] {
display: none;
} |
I'd like the buttons to be as close as possible to the ui section where we set the image resolution. See here for example the extension is in between others and quite far from where it should be. Ideally this shouldn't be an extension but a core part of the ui |
There are several ways to handle this that I have done. Fist we will stick with the process that you are trying to use, and that is "after_component", but if you want finer control, like injecting it inside the "dimensions" row instead of after/before it, then we can explore those options. Gradio components have a flag called 'render'. with gr.Row(elem_id=f'{"img" if is_img2img else "txt"}2img_row_aspect_ratio', render=False) as self.ratio_row: Then in the def after_component(self, component, **kwargs):
if kwargs.get("elem_id") == "txt2img_width":
self.ratio_row.render() But, 'after_components' and 'before_components' is called before the 'ui' method. So your choices become, define these rows somewhere like in the 'init' method, then use the 'with' keyword in the 'ui' method: class MyScript():
def __init__(self):
self.ratio_row = gr.Row(elem_id=f'{"img" if is_img2img else "txt"}2img_row_aspect_ratio', render=False)
def ui(self):
with self.ratio_row:
#define your components here
def after_component(self, *args, **kwargs):
#your logic to find target
self.ratio_row.render() Or move everything from the ui method to the after_component method: class MyScript():
def ui(self):
pass
def after_component(self, *args, **kwargs):
if whatever_ matches:
self.my_ui_stuff() |
On my machine, this extension is installed at I'm not suggesting the repo be named that though, I just handle my extensions differently and slightly more manually (as git submodules). Very related: AUTOMATIC1111/stable-diffusion-webui#8011 |
@Gerschel What about waiting until the UI has loaded and moving the element using Javascript and |
@roamindev Then you could use "insertAdjacentElement" on the target. Something like: target = gradioApp().getElementById("some_element_id")
/* SOME POSITIONING NOTES
'beforebegin'
<ele>
'afterbegin'
<otherele>
'beforeend'
</ele>
'afterend'
*/
target.insertAdjacentElement("afterend", gradioApp().querySelector("my_row")) |
Adding the following to
This is stable against updates, as long the extension ID in CSS is not altered by the maintainers. |
The extensions are ordered in alphabetical order.
Is the sorting done on
title
method? If so we can hack the UI by giving this extension a name likeAAAspect ratio selector
or similar?The text was updated successfully, but these errors were encountered: