Skip to content

theme

theme

ThemePart and closely related objects.

ThemePart

ThemePart(
    partname: PackURI,
    content_type: str,
    element: BaseOxmlElement,
    package: Package,
)

Bases: XmlPart

Proxy for word/theme/theme1.xml, the theme a document resolves against.

A document that sets no explicit w:rFonts/@w:ascii anywhere — which is most documents produced from a Word template — has its actual typefaces here, reached through the minorHAnsi-style tokens in Font.theme.

Source code in src/docx/opc/part.py
def __init__(
    self, partname: PackURI, content_type: str, element: BaseOxmlElement, package: Package
):
    super(XmlPart, self).__init__(partname, content_type, package=package)
    self._element = element

theme

theme() -> Theme

The Theme object for this part.

Source code in src/docx/parts/theme.py
@lazyproperty
def theme(self) -> Theme:
    """The |Theme| object for this part."""
    from docx.theme import Theme

    return Theme(self.element, self)