#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2019, Anaconda, Inc., and Bokeh Contributors.
# All rights reserved.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------
''' Various kinds of input widgets and form controls.
'''
#-----------------------------------------------------------------------------
# Boilerplate
#-----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
log = logging.getLogger(__name__)
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# Standard library imports
# External imports
# Bokeh imports
from ...core.has_props import abstract
from ...core.properties import Date, Either, Float, Instance, Int, List, String, Tuple, Dict
from ..callbacks import Callback
from .widget import Widget
#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------
__all__ = (
'AutocompleteInput',
'DatePicker',
'InputWidget',
'MultiSelect',
'PasswordInput',
'Select',
'TextInput',
'TextAreaInput'
)
#-----------------------------------------------------------------------------
# Dev API
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# General API
#-----------------------------------------------------------------------------
[docs]class TextInput(InputWidget):
''' Single-line input widget.
'''
value = String(default="", help="""
Initial or entered text value.
""")
callback = Instance(Callback, help="""
A callback to run in the browser whenever the user unfocuses the
``TextInput`` widget by hitting Enter or clicking outside of the text box
area.
""")
placeholder = String(default="", help="""
Placeholder for empty input field
""")
[docs]class TextAreaInput(TextInput):
''' Multi-line input widget.
'''
cols = Int(default=20, help="""
Specifies the width of the text area (in average character width). Default: 20
""")
rows = Int(default=2, help="""
Specifies the height of the text area (in lines). Default: 2
""")
max_length = Int(default=500, help="""
Max count of characters in field
""")
[docs]class Select(InputWidget):
''' Single-select widget.
'''
options = Either( List(Either(String, Tuple(Either(Int,String), String))),
Dict(String, List(Either(String, Tuple(Either(Int,String), String)))), help="""
Available selection options. Options may be provided either as a list of
possible string values, or as a list of tuples, each of the form
``(value, label)``. In the latter case, the visible widget text for each
value will be corresponding given label. Option groupings can be provided
by supplying a dictionary object whose values are in the aforementioned
list format
""")
value = String(default="", help="""
Initial or selected value.
""")
callback = Instance(Callback, help="""
A callback to run in the browser whenever the current Select dropdown
value changes.
""")
[docs]class MultiSelect(InputWidget):
''' Multi-select widget.
'''
options = List(Either(String, Tuple(String, String)), help="""
Available selection options. Options may be provided either as a list of
possible string values, or as a list of tuples, each of the form
``(value, label)``. In the latter case, the visible widget text for each
value will be corresponding given label.
""")
value = List(String, help="""
Initial or selected values.
""")
callback = Instance(Callback, help="""
A callback to run in the browser whenever the current selection value
changes.
""")
size = Int(default=4, help="""
The number of visible options in the dropdown list. (This uses the
``select`` HTML element's ``size`` attribute. Some browsers might not
show less than 3 options.)
""")
[docs]class DatePicker(InputWidget):
''' Calendar-based date picker widget.
'''
value = Date(help="""
The initial or picked date.
""")
min_date = Date(default=None, help="""
Optional earliest allowable date.
""")
max_date = Date(default=None, help="""
Optional latest allowable date.
""")
callback = Instance(Callback, help="""
A callback to run in the browser whenever the current date value changes.
""")
#-----------------------------------------------------------------------------
# Private API
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------