1
0

checkbox.py 741 B

123456789101112131415161718192021
  1. from typing import Awaitable, Callable, Optional, Union
  2. import justpy as jp
  3. from .bool_element import BoolElement
  4. class Checkbox(BoolElement):
  5. def __init__(self,
  6. text: str = '',
  7. *,
  8. value: bool = False,
  9. on_change: Optional[Union[Callable, Awaitable]] = None,
  10. ):
  11. """Checkbox Element
  12. :param text: the label to display next to the checkbox
  13. :param value: set to `True` if it should be checked initally; default is `False`
  14. :param on_change: callback to execute when value changes
  15. """
  16. view = jp.QCheckbox(text=text, input=self.handle_change)
  17. super().__init__(view, value=value, on_change=on_change)