toggle.py 853 B

123456789101112131415161718192021222324
  1. import justpy as jp
  2. from typing import Callable, List, Dict, Union
  3. from .choice_element import ChoiceElement
  4. class Toggle(ChoiceElement):
  5. def __init__(self,
  6. options: Union[List, Dict],
  7. value: any = None,
  8. on_change: Callable = None,
  9. design: str = '',
  10. classes: str = '',
  11. ):
  12. """Toggle Element
  13. :param options: a list or dict specifying the options
  14. :param value: the inital value
  15. :param on_change: callback when selection changes
  16. :param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/toggle>`_)
  17. """
  18. view = jp.QBtnToggle(input=self.handle_change)
  19. super().__init__(view, value, options, on_change, design=design, classes=classes)