moved Checkbox into own file, import to widgets
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
|
29
kabuki/widgets/checkbox.py
Normal file
29
kabuki/widgets/checkbox.py
Normal 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)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user