Skip to content

Theme Management

Theme management in pptcraft centers on three baked templates (corporate, dark-tech, minimal) that are discovered via a helper module and built by rewriting the XML of a baseline python-pptx presentation. The build process injects specific color palettes and font schemes into the OpenXML theme parts, while also generating static taskpane icons for the Office add-in manifest.

The ppt_craft.themes package exposes a discovery layer that identifies available templates and their build status. The KNOWN_THEMES constant defines the valid template names, and the list_themes() function iterates over them to report whether the .pptx file exists and its size, or indicates that it needs to be built 1. Each theme has a corresponding metadata file (.theme.json) that stores the palette, font names, and slide dimensions, allowing the engine to apply branding without re-parsing the binary .pptx structure 2.

diagram

Themes are constructed by starting with a default Presentation() from python-pptx, which provides standard built-in layouts, and then rewriting the ppt/theme/theme1.xml content. The builder targets the <a:clrScheme> and <a:fontScheme> elements within the OpenXML structure to swap the color palette and font definitions 3. This approach avoids implementing a full slide-master authoring stack while ensuring the resulting files are valid PowerPoint templates 2.

The builder ensures that all theme parts (not just theme1.xml) are processed to handle multi-master decks correctly 3. It normalizes color slots to use <a:srgbClr> elements and updates the <a:latin> typeface attributes for both major (title) and minor (body) fonts. The output is saved as a .pptx file alongside a JSON metadata file containing the theme specifications, including the 16:9 widescreen dimensions (12,192,000 x 6,858,000 EMUs).

The theme build process also generates PNG icons for the Office Add-in taskpane. The build_icons() function creates 16x16, 32x32, and 80x80 pixel images featuring a “C” glyph in a warm rust accent color (#C4763A) on a white background 4. These icons are saved to the static/taskpane directory and are idempotent, meaning existing files are preserved unless the force=True flag is passed. The icons are referenced by the OfficeApp manifest and served directly from the taskpane static assets.