checkbox.py 623 B

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