Slides

Slides objects

The Slides object is accessed using the slides property of Presentation. It is not intended to be constructed directly.

class pptx.slide.Slides[source]

Sequence of slides belonging to an instance of Presentation, having list semantics for access to individual slides. Supports indexed access, len(), and iteration.

add_slide(slide_layout)[source]

Return a newly added slide that inherits layout from slide_layout.

get(slide_id, default=None)[source]

Return the slide identified by integer slide_id in this presentation, or default if not found.

index(slide)[source]

Map slide to an integer representing its zero-based position in this slide collection. Raises ValueError on slide not present.

Slide objects

An individual Slide object is accessed by index from Slides or as the return value of add_slide().

class pptx.slide.Slide[source]

Slide object. Provides access to shapes and slide-level properties.

background

_Background object providing slide background properties.

This property returns a _Background object whether or not the slide overrides the default background or inherits it. Determining which of those conditions applies for this slide is accomplished using the follow_master_background property.

The same _Background object is returned on every call for the same slide object.

element

The lxml element proxied by this object.

follow_master_background

True if this slide inherits the slide master background.

Assigning False causes background inheritance from the master to be interrupted; if there is no custom background for this slide, a default background is added. If a custom background already exists for this slide, assigning False has no effect.

Assigning True causes any custom background for this slide to be deleted and inheritance from the master restored.

has_notes_slide

Return True if this slide has a notes slide, False otherwise. A notes slide is created by notes_slide when one doesn’t exist; use this property to test for a notes slide without the possible side effect of creating one.

name

String representing the internal name of this slide. Returns an empty string (‘’) if no name is assigned. Assigning an empty string or None to this property causes any name to be removed.

notes_slide

Return the NotesSlide instance for this slide. If the slide does not have a notes slide, one is created. The same single instance is returned on each call.

placeholders

Instance of SlidePlaceholders containing sequence of placeholder shapes in this slide.

shapes

Instance of SlideShapes containing sequence of shape objects appearing on this slide.

slide_id

The integer value that uniquely identifies this slide within this presentation. The slide id does not change if the position of this slide in the slide sequence is changed by adding, rearranging, or deleting slides.

slide_layout

SlideLayout object this slide inherits appearance from.

SlideLayout objects

class pptx.slide.SlideLayout(element, part)[source]

Slide layout object. Provides access to placeholders, regular shapes, and slide layout-level properties.

placeholders

Instance of LayoutPlaceholders containing sequence of placeholder shapes in this slide layout, sorted in idx order.

shapes

Instance of LayoutShapes containing the sequence of shapes appearing on this slide layout.

slide_master

Slide master from which this slide layout inherits properties.

SlideMaster objects

class pptx.slide.SlideMaster(element, part)[source]

Slide master object. Provides access to slide layouts. Access to placeholders, regular shapes, and slide master-level properties is inherited from _BaseMaster.

slide_layouts

Sequence of SlideLayout objects belonging to this slide master

SlidePlaceholders objects

class pptx.shapes.shapetree.SlidePlaceholders(element, parent)[source]

Collection of placeholder shapes on a slide. Supports iteration, len(), and dictionary-style lookup on the idx value of the placeholders it contains.

NotesSlide objects

class pptx.slide.NotesSlide(element, part)[source]

Notes slide object. Provides access to slide notes placeholder and other shapes on the notes handout page.

background

_Background object providing slide background properties.

This property returns a _Background object whether or not the slide, master, or layout has an explicitly defined background.

The same _Background object is returned on every call for the same slide object.

element

The lxml element proxied by this object.

name

String representing the internal name of this slide. Returns an empty string (‘’) if no name is assigned. Assigning an empty string or None to this property causes any name to be removed.

notes_placeholder

Return the notes placeholder on this notes slide, the shape that contains the actual notes text. Return None if no notes placeholder is present; while this is probably uncommon, it can happen if the notes master does not have a body placeholder, or if the notes placeholder has been deleted from the notes slide.

notes_text_frame

Return the text frame of the notes placeholder on this notes slide, or None if there is no notes placeholder. This is a shortcut to accommodate the common case of simply adding “notes” text to the notes “page”.

part

The package part containing this object

placeholders

An instance of NotesSlidePlaceholders containing the sequence of placeholder shapes in this notes slide.

shapes

An instance of NotesSlideShapes containing the sequence of shape objects appearing on this notes slide.