3

PowerPoint has themes you can chose from. The selction is like so:

Is there a way to set the theme of a new presentation with python-pptx?

Something like:

from pptx import Presentation

prs = Presentation()
prs.set_theme(theme)
...

On this github issue it suggests creating a powerpoint with a theme and then opening it.

In that starting .pptx file you would include your customized themes. You can do this by creating a presentation that uses all the themes you would like to have available and then deleting all the slides (but not the slide masters or slide layouts). You will be left with an empty presentation having multiple slide masters, each of which has its own set of slide layouts.

Jake P
  • 480
  • 3
  • 19

1 Answers1

4

Basically you create a template with that theme and use that as your starting point (rather than the built-in default theme).

  1. Open a new presentation in PowerPoint with the desired theme.
  2. Save that as .pptx with the name you want, maybe madison.pptx for the third one in the top row in your screenshot.
  3. Use that presentation as your "starting point" when creating a new presentation:

    prs = Presentation("madison.pptx")
    

The new presentation (prs) will have the Madison theme applied.

python-pptx does not yet have the ability to apply a theme to an existing presentation.

scanny
  • 26,423
  • 5
  • 54
  • 80
  • I'm creating several powerpoints with the same content but each has a different theme. Since changing the theme is not supported, what is the best way to "copy" the content into a new powerpoint? Should I programmatically create a new presentation (with the correct theme) and simply copy all shapes for each slide? – Michael Berk Feb 21 '20 at 20:45
  • @scanny Has there been an update to this or is this still the best strategy for using themes? – NikoTumi Feb 21 '21 at 16:43
  • Nope, this is still the best approach. – scanny Feb 22 '21 at 09:30