mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-24 10:54:04 +08:00
textbox-autoheight (#1009)
* textbox-autoheight - add max-lines to textbox * textbox-autoheight - reformat * textbox-autoheight - add demo * textbox-autoheight - tweaks on scripts * textbox-autoheight - fix tests * textbox-autoheight - fix tests * textbox-autoheight - fix tests * textbox-autoheight - convert default max_height from 100 to 20 * textbox-autoheight - convert default max_height from 100 to 20
This commit is contained in:
parent
db481311a6
commit
9cd4c3121f
13
demo/blocks_textbox_max_lines/run.py
Normal file
13
demo/blocks_textbox_max_lines/run.py
Normal file
@ -0,0 +1,13 @@
|
||||
import gradio as gr
|
||||
|
||||
|
||||
def greet(name: str, repeat: int):
|
||||
return "Hello " + name * repeat + "!!"
|
||||
|
||||
|
||||
demo = gr.Interface(
|
||||
fn=greet, inputs=[gr.Textbox(lines=2, max_lines=4), gr.Number()], outputs=gr.component("textarea")
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
@ -250,6 +250,7 @@ class Textbox(Component):
|
||||
default_value: str = "",
|
||||
*,
|
||||
lines: int = 1,
|
||||
max_lines: int = 20,
|
||||
placeholder: Optional[str] = None,
|
||||
label: Optional[str] = None,
|
||||
css: Optional[Dict] = None,
|
||||
@ -258,7 +259,8 @@ class Textbox(Component):
|
||||
"""
|
||||
Parameters:
|
||||
default_value (str): default text to provide in textarea.
|
||||
lines (int): number of line rows to provide in textarea.
|
||||
lines (int): minimum number of line rows to provide in textarea.
|
||||
max_lines (int): maximum number of line rows to provide in textarea.
|
||||
placeholder (str): placeholder hint to provide behind textarea.
|
||||
label (str): component name in interface.
|
||||
"""
|
||||
@ -274,6 +276,7 @@ class Textbox(Component):
|
||||
)
|
||||
default_value = str(default_value)
|
||||
self.lines = lines
|
||||
self.max_lines = max_lines
|
||||
self.placeholder = placeholder
|
||||
self.default_value = default_value
|
||||
self.test_input = default_value
|
||||
@ -283,6 +286,7 @@ class Textbox(Component):
|
||||
def get_template_context(self):
|
||||
return {
|
||||
"lines": self.lines,
|
||||
"max_lines": self.max_lines,
|
||||
"placeholder": self.placeholder,
|
||||
"default_value": self.default_value,
|
||||
**super().get_template_context(),
|
||||
|
@ -124,6 +124,7 @@ XRAY_CONFIG = {
|
||||
"type": "textbox",
|
||||
"props": {
|
||||
"lines": 1,
|
||||
"max_lines": 20,
|
||||
"placeholder": None,
|
||||
"default_value": "",
|
||||
"name": "textbox",
|
||||
@ -318,6 +319,7 @@ XRAY_CONFIG_DIFF_IDS = {
|
||||
"placeholder": None,
|
||||
"default_value": "",
|
||||
"name": "textbox",
|
||||
"max_lines": 20,
|
||||
"label": None,
|
||||
"css": {},
|
||||
"interactive": None,
|
||||
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$(ls | grep CONTRIBUTING.md)" ]; then
|
||||
echo "Please run the script from repo directory"
|
||||
exit -1
|
||||
else
|
||||
echo "Running the tests"
|
||||
python -m pytest --cov=gradio --durations=20 --durations-min=0.1 test/local
|
||||
fi
|
@ -85,6 +85,7 @@ class TestTextbox(unittest.TestCase):
|
||||
text_input.get_template_context(),
|
||||
{
|
||||
"lines": 1,
|
||||
"max_lines": 20,
|
||||
"placeholder": None,
|
||||
"default_value": "",
|
||||
"name": "textbox",
|
||||
@ -1466,6 +1467,7 @@ class TestCarousel(unittest.TestCase):
|
||||
"label": None,
|
||||
"default_value": "",
|
||||
"lines": 1,
|
||||
"max_lines": 20,
|
||||
"css": {},
|
||||
"placeholder": None,
|
||||
"interactive": None,
|
||||
|
@ -439,6 +439,7 @@ class TestCarousel(unittest.TestCase):
|
||||
"label": None,
|
||||
"default_value": "",
|
||||
"lines": 1,
|
||||
"max_lines": 20,
|
||||
"css": {},
|
||||
"placeholder": None,
|
||||
"interactive": None,
|
||||
|
Loading…
Reference in New Issue
Block a user