Last active
August 5, 2017 08:57
-
-
Save WayneKeenan/e3a80d61938fa9e0e6ce7ad85fe89f99 to your computer and use it in GitHub Desktop.
python-pptx slide creation test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pptx import Presentation | |
# for adding shapes | |
from pptx.util import Inches | |
from pptx.enum.shapes import MSO_AUTO_SHAPE_TYPE | |
prs = Presentation() | |
def create_my_default_slide(title, subtitle): | |
title_slide_layout = prs.slide_layouts[0] | |
slide = prs.slides.add_slide(title_slide_layout) | |
slide.shapes.title.text= title | |
slide.placeholders[1].text=subtitle | |
return slide | |
for n in range(1,7): | |
this_slide = create_my_default_slide("Title %d" % n, "sub-title %d" % n) | |
print(len(prs.slides)) | |
# Do some further processing | |
for slide in prs.slides: | |
shapes = slide.shapes | |
left = top = width = height = Inches(1.0) | |
shape = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.RECTANGLE, left, top, width, height) | |
prs.save('test.pptx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment