moved Checkbox into own file, import to widgets

This commit is contained in:
2021-06-21 12:32:20 +02:00
parent 2ea73fb410
commit 66fe3b6c7d
2 changed files with 30 additions and 26 deletions

View File

@ -1,29 +1,4 @@
from bokeh.models import CheckboxGroup
from ..buki import Object
from ..utils import adjust_margin
class Checkbox(Object):
def __init__(self, *args, label=None, **kwargs):
labels = [label] if label is not None else None
cg = CheckboxGroup(*args, labels=labels, **kwargs)
adjust_margin(cg, left=5)
super().__init__(cg)
@property
def active(self):
return bool(self.layout.active)
@active.setter
def active(self, value):
self.layout.active = [0] if value else []
def on_click(self, handler):
def wrapper(state):
handler(bool(state))
self.layout.on_click(wrapper)
from .checkbox import Checkbox

View File

@ -0,0 +1,29 @@
from bokeh.models import CheckboxGroup
from ..buki import Object
from ..utils import adjust_margin
class Checkbox(Object):
def __init__(self, *args, label=None, **kwargs):
labels = [label] if label is not None else None
cg = CheckboxGroup(*args, labels=labels, **kwargs)
adjust_margin(cg, left=5)
super().__init__(cg)
@property
def active(self):
return bool(self.layout.active)
@active.setter
def active(self, value):
self.layout.active = [0] if value else []
def on_click(self, handler):
def wrapper(state):
handler(bool(state))
self.layout.on_click(wrapper)