From d1a262eeeaaabbb14ed41549fd4af7726a26b708 Mon Sep 17 00:00:00 2001 From: YSH Date: Sat, 31 Aug 2024 16:28:52 -0700 Subject: [PATCH 1/2] feat: Add option to sort XYZ plot alphabetically --- modules/shared_options.py | 1 + scripts/xyz_grid.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/shared_options.py b/modules/shared_options.py index 51d51d8ee66..7b5cacca893 100644 --- a/modules/shared_options.py +++ b/modules/shared_options.py @@ -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"), { diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py index 606d72d42af..c24d5a5006d 100644 --- a/scripts/xyz_grid.py +++ b/scripts/xyz_grid.py @@ -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)) # 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): From 20f5bd8d747b93e6883bf913928952aeea0416f0 Mon Sep 17 00:00:00 2001 From: YSH Date: Sat, 31 Aug 2024 16:57:23 -0700 Subject: [PATCH 2/2] feat: XYZ plot sorting to ignore case --- scripts/xyz_grid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py index c24d5a5006d..d5504f27408 100644 --- a/scripts/xyz_grid.py +++ b/scripts/xyz_grid.py @@ -419,7 +419,7 @@ def title(self): def ui(self, is_img2img): _axis_options = copy(axis_options) if opts.xyz_plot_sort_alphabetical: - _axis_options.sort(key=lambda x: (x.label != "Nothing", x.label)) # Sort by label, but keep "Nothing" first + _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]