Skip to content

Commit

Permalink
Added TextAreaInput widget (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
julwin authored and philippjfr committed Sep 24, 2019
1 parent 16ccc5f commit c5695b2
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
87 changes: 87 additions & 0 deletions examples/reference/widgets/TextAreaInput.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import panel as pn\n",
"pn.extension()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from panel.widgets.input import TextAreaInput"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``TextAreaInput`` allows entering any string using a obfuscated text input box.\n",
"\n",
"For more information about listening to widget events and laying out widgets refer to the [widgets user guide](../../user_guide/Widgets.ipynb). Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the [param user guide](../../user_guide/Param.ipynb). To express interactivity entirely using Javascript without the need for a Python server take a look at the [links user guide](../../user_guide/Param.ipynb).\n",
"\n",
"#### Parameters:\n",
"\n",
"For layout and styling related parameters see the [customization user guide](../../user_guide/Customization.ipynb).\n",
"\n",
"##### Core\n",
"\n",
"* **``value``** (str): Any string\n",
"\n",
"##### Display\n",
"\n",
"* **``disabled``** (boolean): Whether the widget is editable\n",
"* **``name``** (str): The title of the widget\n",
"* **``placeholder``** (str): A placeholder string displayed when no value is entered\n",
"* **``max_length``** (int): Max character length of the input field. Defaults to 5000\n",
"\n",
"___"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"text_area_input = pn.widgets.input.TextAreaInput(name='Text Area Input', placeholder='Enter a string here...')\n",
"text_area_input"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"``TextAreaInput.value`` returns a string type that can be read out and set like other widgets:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"text_area_input.value"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"text_area_input.name"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
12 changes: 11 additions & 1 deletion panel/widgets/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
CheckboxGroup as _BkCheckboxGroup, ColorPicker as _BkColorPicker,
DatePicker as _BkDatePicker, Div as _BkDiv, TextInput as _BkTextInput,
PasswordInput as _BkPasswordInput, Spinner as _BkSpinner,
FileInput as _BkFileInput)
FileInput as _BkFileInput, TextAreaInput as _BkTextAreaInput)

from ..util import as_unicode
from .base import Widget
Expand All @@ -38,6 +38,16 @@ class PasswordInput(Widget):

_widget_type = _BkPasswordInput

class TextAreaInput(Widget):

value = param.String(default='', allow_None=True)

placeholder = param.String(default='')

max_length = param.Integer(default=5000)

_widget_type = _BkTextAreaInput

class FileInput(Widget):

accept = param.String(default=None)
Expand Down

0 comments on commit c5695b2

Please sign in to comment.