123456789101112131415161718192021222324252627282930313233 |
- from typing import Any, Callable, Optional
- from .mixins.disableable_element import DisableableElement
- from .mixins.value_element import ValueElement
- class Expansion(ValueElement, DisableableElement):
- def __init__(self,
- text: Optional[str] = None, *,
- icon: Optional[str] = None,
- value: bool = False,
- on_value_change: Optional[Callable[..., Any]] = None
- ) -> None:
- """Expansion Element
- Provides an expandable container.
- :param text: title text
- :param icon: optional icon (default: None)
- :param value: whether the expansion should be opened on creation (default: `False`)
- :param on_value_change: callback to execute when value changes
- """
- super().__init__(tag='q-expansion-item', value=value, on_value_change=on_value_change)
- if text is not None:
- self._props['label'] = text
- self._props['icon'] = icon
- def open(self) -> None:
- self.value = True
- def close(self) -> None:
- self.value = False
|