Paper Office
paper-pptxAPI referenceshapes.shapetree

MasterPlaceholders

paper-pptx 0.2.0 API reference

Sequence of MasterPlaceholder representing the placeholder shapes on a slide master.

Attributes

__iter__

attribute__iter__Callable[[], Iterator[MasterPlaceholder]]

element

attributeelement

The lxml element proxied by this object.

parent

attributeparent

The ancestor proxy object to this one.

For example, the parent of a shape is generally the SlideShapes object that contains it.

part

attributepartXmlPart

The package part containing this object.

turbo_add_enabled

attributeturbo_add_enabledbool

True if "turbo-add" mode is enabled. Read/Write.

EXPERIMENTAL: This feature can radically improve performance when adding large numbers (hundreds of shapes) to a slide. It works by caching the last shape ID used and incrementing that value to assign the next shape id. This avoids repeatedly searching all shape ids in the slide each time a new ID is required.

Performance is not noticeably improved for a slide with a relatively small number of shapes, but because the search time rises with the square of the shape count, this option can be useful for optimizing generation of a slide composed of many shapes.

Shape-id collisions can occur (causing a repair error on load) if more than one Slide object is used to interact with the same slide in the presentation. Note that the Slides collection creates a new Slide object each time a slide is accessed (e.g. slide = prs.slides[0], so you must be careful to limit use to a single Slide object.

Functions

__getitem__

func__getitem__(idx: int) -> BaseShape

Return shape at idx in sequence, e.g. shapes[2].

paramidxint

Returns

pptx.shapes.base.BaseShape

__len__

func__len__() -> int

Return count of shapes in this shape tree.

A group shape contributes 1 to the total, without regard to the number of shapes contained in the group.

Returns

int

clone_placeholder

funcclone_placeholder(placeholder: LayoutPlaceholder) -> None

Add a new placeholder shape based on placeholder.

paramplaceholderLayoutPlaceholder

Returns

None

get

funcget(ph_type: PP_PLACEHOLDER, default: MasterPlaceholder | None = None)

Return the first placeholder shape with type ph_type (e.g. 'body').

Returns default if no such placeholder shape is present in the collection.

paramph_typePP_PLACEHOLDER
paramdefaultMasterPlaceholder | None
= None

ph_basename

funcph_basename(ph_type: PP_PLACEHOLDER) -> str

Return the base name for a placeholder of ph_type in this shape collection.

There is some variance between slide types, for example a notes slide uses a different name for the body placeholder, so this method can be overriden by subclasses.

paramph_typePP_PLACEHOLDER

Returns

str

On this page