|
@@ -1,19 +1,22 @@
|
|
from typing import Callable, Optional
|
|
from typing import Callable, Optional
|
|
|
|
|
|
-import justpy as jp
|
|
|
|
-
|
|
|
|
|
|
+from .binding_mixins import BindTextMixin
|
|
from .bool_element import BoolElement
|
|
from .bool_element import BoolElement
|
|
|
|
|
|
|
|
|
|
-class Checkbox(BoolElement):
|
|
|
|
|
|
+class Checkbox(BoolElement, BindTextMixin):
|
|
|
|
|
|
- def __init__(self, text: str = '', *, value: bool = False, on_change: Optional[Callable] = None):
|
|
|
|
|
|
+ def __init__(self, text: str = '', *, value: bool = False, on_change: Optional[Callable] = None) -> None:
|
|
"""Checkbox
|
|
"""Checkbox
|
|
|
|
|
|
:param text: the label to display next to the checkbox
|
|
:param text: the label to display next to the checkbox
|
|
:param value: whether it should be checked initially (default: `False`)
|
|
:param value: whether it should be checked initially (default: `False`)
|
|
:param on_change: callback to execute when value changes
|
|
:param on_change: callback to execute when value changes
|
|
"""
|
|
"""
|
|
- view = jp.QCheckbox(text=text, input=self.handle_change, temp=False)
|
|
|
|
|
|
+ super().__init__('q-checkbox', value=value, on_change=on_change)
|
|
|
|
+ self.text = text
|
|
|
|
+ self._text = text
|
|
|
|
|
|
- super().__init__(view, value=value, on_change=on_change)
|
|
|
|
|
|
+ def on_text_change(self, text: str) -> None:
|
|
|
|
+ self._text = text
|
|
|
|
+ self.update()
|