1
|
6
|
import param
|
2
|
|
|
3
|
6
|
from bokeh.themes import Theme as _BkTheme, _dark_minimal
|
4
|
|
|
5
|
|
|
6
|
6
|
class Theme(param.Parameterized):
|
7
|
|
"""
|
8
|
|
A Theme customizes the look and feel of a Template by providing
|
9
|
|
custom CSS and bokeh Theme class.
|
10
|
|
|
11
|
|
When adding a new theme a generic Theme class should be created,
|
12
|
|
which is what users will important and set on the Template.theme
|
13
|
|
parameter. Additionally a concrete implementation of the Theme
|
14
|
|
should be created specific to the particular Template being used.
|
15
|
|
|
16
|
|
For example when adding a DarkTheme there should be a
|
17
|
|
corresponding MaterialDarkTheme which declares the Template class
|
18
|
|
on its _template class variable. In this way a user can always use
|
19
|
|
the generic Theme but the actual CSS and bokeh Theme will depend
|
20
|
|
on the exact Template being used.
|
21
|
|
"""
|
22
|
|
|
23
|
6
|
css = param.Filename()
|
24
|
|
|
25
|
6
|
bokeh_theme = param.ClassSelector(class_=(_BkTheme, str))
|
26
|
|
|
27
|
6
|
_template = None
|
28
|
|
|
29
|
6
|
__abstract = True
|
30
|
|
|
31
|
6
|
@classmethod
|
32
|
1
|
def find_theme(cls, template_type):
|
33
|
6
|
if cls._template is template_type:
|
34
|
0
|
return cls
|
35
|
6
|
for theme in param.concrete_descendents(cls).values():
|
36
|
6
|
if theme._template is template_type:
|
37
|
6
|
return theme
|
38
|
|
|
39
|
|
|
40
|
6
|
class DefaultTheme(Theme):
|
41
|
|
"""
|
42
|
|
The DefaultTheme uses the standard Panel color palette.
|
43
|
|
"""
|
44
|
|
|
45
|
|
|
46
|
|
|
47
|
6
|
BOKEH_DARK = dict(_dark_minimal.json)
|
48
|
|
|
49
|
6
|
BOKEH_DARK['attrs']['Figure'].update({
|
50
|
|
"background_fill_color": "#3f3f3f",
|
51
|
|
"border_fill_color": "#2f2f2f",
|
52
|
|
|
53
|
|
})
|
54
|
|
|
55
|
6
|
class DarkTheme(Theme):
|
56
|
|
"""
|
57
|
|
The DefaultTheme uses the standard Panel color palette.
|
58
|
|
"""
|
59
|
|
|
60
|
6
|
bokeh_theme = param.ClassSelector(class_=(_BkTheme, str),
|
61
|
|
default=_BkTheme(json=BOKEH_DARK))
|