Skip to content

ThemeDefinition

Encapsulates the name, color palette, and metadata for a ttkbootstrap theme.

A ThemeDefinition is a lightweight container that pairs a theme name with its Colors object and whether it is a light or dark theme. The Style engine consumes ThemeDefinition instances to build widget styles and images for the active theme.

Source code in src/ttkbootstrap/style.py
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
class ThemeDefinition:
    """Encapsulates the name, color palette, and metadata for a
    ttkbootstrap theme.

    A ThemeDefinition is a lightweight container that pairs a theme name
    with its Colors object and whether it is a light or dark theme. The
    Style engine consumes ThemeDefinition instances to build widget
    styles and images for the active theme.
    """

    def __init__(self, name, colors, themetype=LIGHT):
        """
        Parameters:

            name (str):
                The name of the theme.

            colors (Colors or dict):
                A Colors instance or a dict of color values.

            themetype (str):
                Specifies whether the theme is **light** or **dark**.
        """
        self.name = name
        self.colors = colors if isinstance(colors, Colors) else Colors(**colors)
        self.type = themetype

    def __repr__(self):
        return " ".join(
            [
                f"name={self.name},",
                f"type={self.type},",
                f"colors={self.colors}",
            ]
        )

__init__(name, colors, themetype=LIGHT)

Parameters:

name (str):
    The name of the theme.

colors (Colors or dict):
    A Colors instance or a dict of color values.

themetype (str):
    Specifies whether the theme is **light** or **dark**.
Source code in src/ttkbootstrap/style.py
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
def __init__(self, name, colors, themetype=LIGHT):
    """
    Parameters:

        name (str):
            The name of the theme.

        colors (Colors or dict):
            A Colors instance or a dict of color values.

        themetype (str):
            Specifies whether the theme is **light** or **dark**.
    """
    self.name = name
    self.colors = colors if isinstance(colors, Colors) else Colors(**colors)
    self.type = themetype