From c5695b2e28b2c7329de1a3dbedb02ab441f8beda Mon Sep 17 00:00:00 2001 From: Julius Winkelmann Date: Tue, 24 Sep 2019 16:28:05 +0200 Subject: [PATCH] Added TextAreaInput widget (#658) --- .../reference/widgets/TextAreaInput.ipynb | 87 +++++++++++++++++++ panel/widgets/input.py | 12 ++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 examples/reference/widgets/TextAreaInput.ipynb diff --git a/examples/reference/widgets/TextAreaInput.ipynb b/examples/reference/widgets/TextAreaInput.ipynb new file mode 100644 index 0000000000..95a5fb07be --- /dev/null +++ b/examples/reference/widgets/TextAreaInput.ipynb @@ -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 +} diff --git a/panel/widgets/input.py b/panel/widgets/input.py index c20f50cd91..f63c471c44 100644 --- a/panel/widgets/input.py +++ b/panel/widgets/input.py @@ -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 @@ -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)