FolderInput¶
Bases: InputElement
_value_type: type
property
¶
Get the FolderInput value type: a single string str
.
value: Optional[str]
property
¶
Returns:
Type | Description |
---|---|
Optional[str]
|
The path or list of paths for the selected folder: if paths are not absolute, then |
Optional[str]
|
they are considered relative to the data root folder. See |
Optional[str]
|
Best Practices With Data for more information. |
__init__(key, value, label=None, count=None, optional=False, hide_when_disabled=False, kwargs)
¶
A single folder selector.
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]]]
|
Path to folder. Provided folder doesn't necessarily have to exist for the Streamlit mode, however its existence will be checked at execution time. If path is not absolute, then it is considered relative to the data root folder. See Best Practices With Data for more information. |
required |
label |
Optional[str]
|
Label to display left of the folder selector. |
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
|
**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 folder_input, Mode, Project
Project().mode = Mode.EXECUTE
widget = folder_input(
key="FolderInput",
value="/path/to/"
)
print(widget)
"/path/to/"
_validate(value)
¶
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the path does not exist or is not a folder. |
imports()
staticmethod
¶
Returns:
Type | Description |
---|---|
List[str]
|
Python import statements required by the Streamlit code. |
init()
staticmethod
¶
Returns:
Type | Description |
---|---|
str
|
The Python statements that must be initialized before being used by the Streamlit code. |
streamlit(id)
¶
Returns:
Type | Description |
---|---|
str
|
The Streamlit code for a folder selection ( |
str
|
|