Paper Office
paper-pptxAPI referenceshapes.shapetree

LayoutShapes

paper-pptx 0.2.0 API reference

Sequence of shapes appearing on a slide layout.

The first shape in the sequence is the backmost in z-order and the last shape is topmost. Supports indexed access, len(), index(), and iteration.

Attributes

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

__iter__

func__iter__() -> Iterator[BaseShape]

Generate a reference to each shape in the collection, in sequence.

Returns

typing.Iterator[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

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