From dd7b69bea8cda43ee5f829fa492b722a296f9f36 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 31 Aug 2025 12:39:59 -0400 Subject: [PATCH] modernui configurable grid images size Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 2 ++ modules/shared.py | 9 ++++----- modules/ui_components.py | 35 ++--------------------------------- 3 files changed, 8 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6639ad0df..f03eb2b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ - configurable horizontal vs vertical panel layout in settings -> user interface -> panel min width *example*: if panel width is less than specified value, layout switches to verical + - configurable grid images size + in *settings -> user interface -> grid image size* - **Offloading** - enable offload during pre-forward by default - improve offloading of models with multiple dits diff --git a/modules/shared.py b/modules/shared.py index e85bd8bc7..b4da378f4 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -532,10 +532,10 @@ options_templates.update(options_section(('ui', "User Interface"), { "subpath": OptionInfo("", "Mount URL subpath"), "ui_request_timeout": OptionInfo(120000, "UI request timeout", gr.Slider, {"minimum": 1000, "maximum": 300000, "step": 10}), - "cards_sep_ui": OptionInfo("

Card options

", "", gr.HTML), - "extra_networks_card_size": OptionInfo(140, "UI card size (px)", gr.Slider, {"minimum": 20, "maximum": 2000, "step": 1}), - "extra_networks_card_cover": OptionInfo("sidebar", "UI position", gr.Radio, {"choices": ["cover", "inline", "sidebar"]}), - "extra_networks_card_square": OptionInfo(True, "UI disable variable aspect ratio"), + "cards_sep_ui": OptionInfo("

Networks panel

", "", gr.HTML), + "extra_networks_card_size": OptionInfo(140, "Network card size (px)", gr.Slider, {"minimum": 20, "maximum": 2000, "step": 1}), + "extra_networks_card_cover": OptionInfo("sidebar", "Network panel position", gr.Radio, {"choices": ["cover", "inline", "sidebar"]}), + "extra_networks_card_square": OptionInfo(True, "Disable variable aspect ratio"), "other_sep_ui": OptionInfo("

Other...

", "", gr.HTML), "ui_locale": OptionInfo("Auto", "UI locale", gr.Dropdown, lambda: {"choices": theme.list_locales()}), @@ -555,7 +555,6 @@ options_templates.update(options_section(('ui', "User Interface"), { "return_mask_composite": OptionInfo(False, "Inpainting include masked composite in results"), "send_seed": OptionInfo(True, "Send seed when sending prompt or image to other interface", gr.Checkbox, {"visible": False}), "send_size": OptionInfo(False, "Send size when sending prompt or image to another interface", gr.Checkbox, {"visible": False}), - })) options_templates.update(options_section(('live-preview', "Live Previews"), { diff --git a/modules/ui_components.py b/modules/ui_components.py index e2efc94c5..0b4ad86ed 100644 --- a/modules/ui_components.py +++ b/modules/ui_components.py @@ -9,9 +9,7 @@ class FormComponent: gr.Dropdown.get_expected_parent = FormComponent.get_expected_parent -class ToolButton(FormComponent, gr.Button): - """Small button with single emoji as text, fits inside gradio forms""" - +class ToolButton(FormComponent, gr.Button): # small button with single emoji as text def __init__(self, *args, **kwargs): classes = kwargs.pop("elem_classes", []) super().__init__(*args, elem_classes=["tool", *classes], **kwargs) @@ -19,66 +17,49 @@ class ToolButton(FormComponent, gr.Button): def get_block_name(self): return "button" +### unused components below for compatibility with extensions ### class FormRow(FormComponent, gr.Row): # unused - """Same as gr.Row but fits inside gradio forms""" - def get_block_name(self): return "row" class FormColumn(FormComponent, gr.Column): # unused - """Same as gr.Column but fits inside gradio forms""" - def get_block_name(self): return "column" class FormGroup(FormComponent, gr.Group): # unused - """Same as gr.Row but fits inside gradio forms""" - def get_block_name(self): return "group" class FormHTML(FormComponent, gr.HTML): # unused - """Same as gr.HTML but fits inside gradio forms""" - def get_block_name(self): return "html" class FormColorPicker(FormComponent, gr.ColorPicker): # unused - """Same as gr.ColorPicker but fits inside gradio forms""" - def get_block_name(self): return "colorpicker" class DropdownMulti(FormComponent, gr.Dropdown): # unused - """Same as gr.Dropdown but always multiselect""" def __init__(self, **kwargs): super().__init__(multiselect=True, **kwargs) - def get_block_name(self): return "dropdown" class DropdownEditable(FormComponent, gr.Dropdown): # unused - """Same as gr.Dropdown but allows editing value""" def __init__(self, **kwargs): super().__init__(allow_custom_value=True, **kwargs) - def get_block_name(self): return "dropdown" class InputAccordion(gr.Checkbox): # unused - """A gr.Accordion that can be used as an input - returns True if open, False if closed. - Actaully just a hidden checkbox, but creates an accordion that follows and is followed by the state of the checkbox. - """ global_index = 0 - def __init__(self, value, **kwargs): self.accordion_id = kwargs.get('elem_id') if self.accordion_id is None: @@ -97,15 +78,6 @@ class InputAccordion(gr.Checkbox): # unused self.accordion = gr.Accordion(**kwargs_accordion) def extra(self): - """Allows you to put something into the label of the accordion. - Use it like this: - ``` - with InputAccordion(False, label="Accordion") as acc: - with acc.extra(): - FormHTML(value="hello", min_width=0) - ... - ``` - """ return gr.Column(elem_id=self.accordion_id + '-extra', elem_classes='input-accordion-extra', min_width=0) def __enter__(self): @@ -120,11 +92,8 @@ class InputAccordion(gr.Checkbox): # unused class ResizeHandleRow(gr.Row): # unusued - """Same as gr.Row but fits inside gradio forms""" - def __init__(self, **kwargs): super().__init__(**kwargs) self.elem_classes.append("resize-handle-row") - def get_block_name(self): return "row"