Skip to content
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

feat: Allows the XYZ plot to be sorted alphabetically #16448

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/shared_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
"txt2img_settings_accordion": OptionInfo(False, "Settings in txt2img hidden under Accordion").needs_reload_ui(),
"img2img_settings_accordion": OptionInfo(False, "Settings in img2img hidden under Accordion").needs_reload_ui(),
"interrupt_after_current": OptionInfo(True, "Don't Interrupt in the middle").info("when using Interrupt button, if generating more than one image, stop after the generation of an image has finished, instead of immediately"),
"xyz_plot_sort_alphabetical": OptionInfo(True, "Sort XYZ plot options alphabetically").needs_reload_ui(),
}))

options_templates.update(options_section(('ui', "User interface", "ui"), {
Expand Down
6 changes: 5 additions & 1 deletion scripts/xyz_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ def title(self):
return "X/Y/Z plot"

def ui(self, is_img2img):
self.current_axis_options = [x for x in axis_options if type(x) == AxisOption or x.is_img2img == is_img2img]
_axis_options = copy(axis_options)
if opts.xyz_plot_sort_alphabetical:
_axis_options.sort(key=lambda x: (x.label != "Nothing", x.label.lower())) # Sort by label, but keep "Nothing" first

self.current_axis_options = [x for x in _axis_options if type(x) == AxisOption or x.is_img2img == is_img2img]

with gr.Row():
with gr.Column(scale=19):
Expand Down