1 2
import param
2

3 2
from bokeh.themes import Theme as _BkTheme, _dark_minimal
4

5

6 2
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 2
    css = param.Filename()
24

25 2
    bokeh_theme = param.ClassSelector(class_=(_BkTheme, str))
26

27 2
    _template = None
28

29 2
    __abstract = True
30

31 2
    @classmethod
32
    def find_theme(cls, template_type):
33 0
        if cls._template is template_type:
34 0
            return cls
35 0
        for theme in param.concrete_descendents(cls).values():
36 0
            if theme._template is template_type:
37 0
                return theme
38

39

40 2
class DefaultTheme(Theme):
41
    """
42
    The DefaultTheme uses the standard Panel color palette.
43
    """
44

45

46

47 2
BOKEH_DARK = dict(_dark_minimal.json)
48

49 2
BOKEH_DARK['attrs']['Figure'].update({
50
    "background_fill_color": "#3f3f3f",
51
    "border_fill_color": "#2f2f2f",
52

53
})
54

55 2
class DarkTheme(Theme):
56
    """
57
    The DefaultTheme uses the standard Panel color palette.
58
    """
59

60 2
    bokeh_theme = param.ClassSelector(class_=(_BkTheme, str),
61
                                      default=_BkTheme(json=BOKEH_DARK))

Read our documentation on viewing source code .

Loading