aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ui_components.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-03-20 13:09:36 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-03-25 06:00:36 +0000
commit9f0da9f6edfb9be1d69ba3492a61d96db769307b (patch)
tree4cac745943f5bc425586c81bdda2cdef195111b9 /modules/ui_components.py
parenta9fed7c364061ae6efb37f797b6b522cb3cf7aa2 (diff)
downloadstable-diffusion-webui-gfx803-9f0da9f6edfb9be1d69ba3492a61d96db769307b.tar.gz
stable-diffusion-webui-gfx803-9f0da9f6edfb9be1d69ba3492a61d96db769307b.tar.bz2
stable-diffusion-webui-gfx803-9f0da9f6edfb9be1d69ba3492a61d96db769307b.zip
initial gradio 3.22 support
Diffstat (limited to 'modules/ui_components.py')
-rw-r--r--modules/ui_components.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/modules/ui_components.py b/modules/ui_components.py
index 284ca0cf..2b1da2cb 100644
--- a/modules/ui_components.py
+++ b/modules/ui_components.py
@@ -1,55 +1,61 @@
import gradio as gr
-class ToolButton(gr.Button, gr.components.FormComponent):
- """Small button with single emoji as text, fits inside gradio forms"""
+class FormComponent:
+ def get_expected_parent(self):
+ return gr.components.Form
- def __init__(self, **kwargs):
- super().__init__(variant="tool", **kwargs)
- def get_block_name(self):
- return "button"
+gr.Dropdown.get_expected_parent = FormComponent.get_expected_parent
-class ToolButtonTop(gr.Button, gr.components.FormComponent):
- """Small button with single emoji as text, with extra margin at top, fits inside gradio forms"""
+class ToolButton(FormComponent, gr.Button):
+ """Small button with single emoji as text, fits inside gradio forms"""
- def __init__(self, **kwargs):
- super().__init__(variant="tool-top", **kwargs)
+ def __init__(self, *args, **kwargs):
+ classes = kwargs.pop("elem_classes", [])
+ super().__init__(*args, elem_classes=["tool", *classes], **kwargs)
def get_block_name(self):
return "button"
-class FormRow(gr.Row, gr.components.FormComponent):
+class FormRow(FormComponent, gr.Row):
"""Same as gr.Row but fits inside gradio forms"""
def get_block_name(self):
return "row"
-class FormGroup(gr.Group, gr.components.FormComponent):
+class FormColumn(FormComponent, gr.Column):
+ """Same as gr.Column but fits inside gradio forms"""
+
+ def get_block_name(self):
+ return "column"
+
+
+class FormGroup(FormComponent, gr.Group):
"""Same as gr.Row but fits inside gradio forms"""
def get_block_name(self):
return "group"
-class FormHTML(gr.HTML, gr.components.FormComponent):
+class FormHTML(FormComponent, gr.HTML):
"""Same as gr.HTML but fits inside gradio forms"""
def get_block_name(self):
return "html"
-class FormColorPicker(gr.ColorPicker, gr.components.FormComponent):
+class FormColorPicker(FormComponent, gr.ColorPicker):
"""Same as gr.ColorPicker but fits inside gradio forms"""
def get_block_name(self):
return "colorpicker"
-class DropdownMulti(gr.Dropdown):
+class DropdownMulti(FormComponent, gr.Dropdown):
"""Same as gr.Dropdown but always multiselect"""
def __init__(self, **kwargs):
super().__init__(multiselect=True, **kwargs)