-
-
Notifications
You must be signed in to change notification settings - Fork 473
/
spacer.py
56 lines (38 loc) · 1.53 KB
/
spacer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Spacer components to add horizontal or vertical space to a layout.
"""
import param
from bokeh.models import Div as BkDiv, Spacer as BkSpacer
from ..reactive import Reactive
class Spacer(Reactive):
"""Empty object used to control formatting (using positive or negative space)"""
_bokeh_model = BkSpacer
def _get_model(self, doc, root=None, parent=None, comm=None):
properties = self._process_param_change(self._init_properties())
model = self._bokeh_model(**properties)
if root is None:
root = model
self._models[root.ref['id']] = (model, parent)
return model
class VSpacer(Spacer):
"""
Spacer which automatically fills all available vertical space.
"""
sizing_mode = param.Parameter(default='stretch_height', readonly=True)
class HSpacer(Spacer):
"""
Spacer which automatically fills all available horizontal space.
"""
sizing_mode = param.Parameter(default='stretch_width', readonly=True)
class Divider(Reactive):
"""A Divider line"""
width_policy = param.ObjectSelector(default="fit", readonly=True)
_bokeh_model = BkDiv
def _get_model(self, doc, root=None, parent=None, comm=None):
properties = self._process_param_change(self._init_properties())
properties['style'] = {'width': '100%', 'height': '100%'}
model = self._bokeh_model(text='<hr style="margin: 0px">', **properties)
if root is None:
root = model
self._models[root.ref['id']] = (model, parent)
return model