TextInput¶
Bases: InputElement
_value_type: type
property
¶
Get the TextInput value type: string str
.
__init__(key, value, label=None, count=None, optional=False, hide_when_disabled=False, max_chars=None, placeholder=None, multiline=False, kwargs)
¶
A simple text field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
ID of the element. It must be unique as it is the key used to story data in
Project(), otherwise it will lead to conflicts at runtime in both execution and
Streamlit modes. The key will be transformed into snake case and slugified to avoid
any special character or whitespace. Note that an ID cannot start with |
required |
value |
Optional[Union[str, List[str]]]
|
Initial text value. |
required |
label |
Optional[str]
|
Label to display next to the checkbox. |
None
|
count |
Optional[Union[int, str]]
|
Specify the number of occurence of the widget. OneCode typically uses it for the
streamlit case. Note that if |
None
|
optional |
Union[bool, str]
|
Specify whether the value may be None. |
False
|
hide_when_disabled |
bool
|
If element is optional, set it to True to hide it from the interface, otherwise it will be shown disabled. |
False
|
max_chars |
int
|
Maximum number of characters allowed for this text field. |
None
|
placeholder |
str
|
Placeholder text shown whenever there is no value. |
None
|
multiline |
Union[bool, int]
|
Set to True or a height in pixels to make it multiline text area. |
False
|
**kwargs |
Any
|
Extra user meta-data to attach to the element. Argument names cannot overwrite
existing attributes or methods name such as |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
if the |
AttributeError
|
if one the |
Example
from onecode import text_input, Mode, Project
Project().mode = Mode.EXECUTE
widget = text_input(
key="TextInput",
value="OneCode rocks!",
label="My TextInput"
)
print(widget)
"OneCode rocks!"
_validate(value)
¶
No validation is performed.
streamlit(id)
¶
Returns:
Type | Description |
---|---|
str
|
The Streamlit code for a text input field ( |