This creates a new presentation from the built-in default template and
saves it unchanged to a file named ‘yourSuitableName.pptx. Let's add some Slide to it.
PowerPoint Slide 101
The slide layouts in a standard PowerPoint theme always occur in the same sequence. This allows
content from one deck to be pasted into another and be connected with the right new slide layout:
Title (presentation title slide)
Title and Content
Section Header (sometimes called Segue)
Two Content (side by side bullet textboxes)
Comparison (same but additional title for each side by side content box)
Content with Caption
Picture with Caption
In python-pptx, these are prs.slide_layouts through prs.slide_layouts. i.e If you want to add
a slide with Title and Content you have to use prs.slide_layouts, here prs is presentation Object
which can be named anything you desire.
Keep in mind that, there’s no rule they have to appear in this order,
it’s just a convention followed by the themes provided with PowerPoint.
Adding a Slide
frompptximportPresentationprs=Presentation()# Simple Presentation ObjectSLIDE_LAYOUT_TITLE_AND_CONTENT=1# 1 is a slide with Presentation Titleslide1_layout=prs.slide_layouts[SLIDE_LAYOUT_TITLE_AND_CONTENT]# Select a slide with Presentation Titleslide1=prs.slides.add_slide(slide1_layout)# Appends the slide1_layout at the end of collectionsslide1.shapes.title.text="Watch Out!!"# Adds Some Shapesslide1.placeholders.text="The world is Spinning."prs.save('watchout.pptx')
Name this .py file anything you desire like create_presentation.py.
If you run this file you will see that a new .pptx file has been created in your
Note that I am not using MS powerpoint but it works correctly here too.
Now open the file you will see this
If you set SLIDE_LAYOUT_TITLE_AND_CONTENT = 3, then you would see this
Hey there, I'm Nischal.
I am a student, a developer and I specialize in
standards-based Django, JS, HTML, CSS web development.
I love Everything that makes me more Human. While
not Coding, I play and/or watch football.