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[源代码]¶
Sequence of slides belonging to an instance of
Presentation
, having list semantics for access to individual slides. Supports indexed access, len(), and iteration.
Slide
objects¶
An individual Slide
object is accessed by index from Slides
or as the
return value of add_slide()
.
- class pptx.slide.Slide[源代码]¶
Slide object. Provides access to shapes and slide-level properties.
- property 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 thefollow_master_background
property.The same
_Background
object is returned on every call for the same slide object.
- property element¶
The lxml element proxied by this object.
- property 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, assigningFalse
has no effect.Assigning
True
causes any custom background for this slide to be deleted and inheritance from the master restored.
- property 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.
- property 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.
- property 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.
- property 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.
- property slide_layout¶
SlideLayout
object this slide inherits appearance from.
SlideLayouts
objects¶
The SlideLayouts
object is accessed using the
slide_layouts
property of SlideMaster
, typically:
>>> from pptx import Presentation
>>> prs = Presentation()
>>> slide_layouts = prs.slide_master.slide_layouts
As a convenience, since most presentations have only a single slide master, the
SlideLayouts
collection for the first master may be accessed directly from the
Presentation
object:
>>> slide_layouts = prs.slide_layouts
This class is not intended to be constructed directly.
- class pptx.slide.SlideLayouts[源代码]¶
Sequence of slide layouts belonging to a slide-master.
Supports indexed access, len(), iteration, index() and remove().
- get_by_name(name, default=None)[源代码]¶
Return SlideLayout object having name or default if not found.
- index(slide_layout)[源代码]¶
Return zero-based index of slide_layout in this collection.
Raises ValueError if slide_layout is not present in this collection.
- property part¶
The package part containing this object
SlideLayout
objects¶
- class pptx.slide.SlideLayout(element, part)[源代码]¶
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.
- property slide_master¶
Slide master from which this slide layout inherits properties.
- property used_by_slides¶
Tuple of slide objects based on this slide layout.
SlideMasters
objects¶
The SlideMasters
object is accessed using the
slide_masters
property of Presentation
, typically:
>>> from pptx import Presentation
>>> prs = Presentation()
>>> slide_masters = prs.slide_masters
As a convenience, since most presentations have only a single slide master, the
first master may be accessed directly from the Presentation
object without indexing
the collection:
>>> slide_master = prs.slide_master
This class is not intended to be constructed directly.
- class pptx.slide.SlideMasters[源代码]¶
Sequence of
SlideMaster
objects belonging to a presentation.Has list access semantics, supporting indexed access, len(), and iteration.
- property part¶
The package part containing this object
SlideMaster
objects¶
- class pptx.slide.SlideMaster(element, part)[源代码]¶
Slide master object. Provides access to slide layouts. Access to placeholders, regular shapes, and slide master-level properties is inherited from
_BaseMaster
.- slide_layouts[源代码]¶
SlideLayouts
object providing access to this slide-master’s layouts.
SlidePlaceholders
objects¶
NotesSlide
objects¶
- class pptx.slide.NotesSlide(element, part)[源代码]¶
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.
- property element¶
The lxml element proxied by this object.
- property 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.
- property 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.
- property 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”.
- property part¶
The package part containing this object