Paper Office
paper-pptxAPI referenceoxml.shapes.autoshape

CT_Shape

paper-pptx 0.2.0 API reference

p:sp custom element class.

Attributes

cx

attributecxLength

cy

attributecyLength

flipH

attributeflipH

flipV

attributeflipV

get_or_add_txBody

attributeget_or_add_txBodyCallable[[], CT_TextBody]

has_custom_geometry

attributehas_custom_geometry

True if this shape has custom geometry, i.e. is a freeform shape.

A shape has custom geometry if it has a p:spPr/a:custGeom descendant (instead of p:spPr/a:prstGeom).

has_ph_elm

attributehas_ph_elm

True if this shape element has a p:ph descendant, indicating it is a placeholder shape. False otherwise.

is_autoshape

attributeis_autoshape

True if this shape is an auto shape.

A shape is an auto shape if it has a a:prstGeom element and does not have a txBox="1" attribute on cNvSpPr.

is_textbox

attributeis_textbox

True if this shape is a text box.

A shape is a text box if it has a txBox attribute on cNvSpPr that resolves to True. The default when the txBox attribute is missing is False.

ln

attributeln

a:ln grand-child element or None if not present.

nvSpPr

attributenvSpPrCT_ShapeNonVisual
= OneAndOnlyOne('p:nvSpPr')

ph

attributephCT_Placeholder | None

The p:ph descendant element if there is one, None otherwise.

ph_idx

attributeph_idxint

Integer value of placeholder idx attribute.

Raises ValueError if shape is not a placeholder.

ph_orient

attributeph_orientstr

Placeholder orientation, e.g. 'vert'.

Raises ValueError if shape is not a placeholder.

ph_sz

attributeph_szstr

Placeholder size, e.g. ST_PlaceholderSize.HALF.

Raises ValueError if shape is not a placeholder.

ph_type

attributeph_type

Placeholder type, e.g. ST_PlaceholderType.TITLE ('title').

Raises ValueError if shape is not a placeholder.

prst

attributeprst

Value of prst attribute of a:prstGeom element or None if not present.

prstGeom

attributeprstGeomCT_PresetGeometry2D

Reference to a:prstGeom child element.

None if this shape doesn't have one, for example, if it's a placeholder shape.

rot

attributerotfloat

Float representing degrees this shape is rotated clockwise.

shape_id

attributeshape_id

Integer id of this shape

shape_name

attributeshape_name

Name of this shape

spPr

attributespPrCT_ShapeProperties
= OneAndOnlyOne('p:spPr')

txBody

attributetxBodyCT_TextBody | None
= ZeroOrOne('p:txBody', successors=('p:extLst',))

x

attributexLength

xfrm

attributexfrm

The a:xfrm grandchild element or None if not found.

This version works for p:sp, p:cxnSp, and p:pic elements, others will need to override.

xml

attributexmlstr

XML string for this element, suitable for testing purposes.

Pretty printed for readability and without an XML declaration at the top.

y

attributeyLength

Functions

add_path

funcadd_path(w: Length, h: Length) -> CT_Path2D
paramwLength
paramhLength

Returns

pptx.oxml.shapes.autoshape.CT_Path2D

first_child_found_in

funcfirst_child_found_in(*tagnames: str) -> _Element | None

First child with tag in tagnames, or None if not found.

paramtagnamesstr
= ()

Returns

lxml.etree._Element | None

get_or_add_ln

funcget_or_add_ln()

Return the a:ln grandchild element, newly added if not present.

get_or_add_xfrm

funcget_or_add_xfrm()

Return the a:xfrm grandchild element, newly-added if not present.

This version works for p:sp, p:cxnSp, and p:pic elements, others will need to override.

insert_element_before

funcinsert_element_before(elm: ElementBase, *tagnames: str)
paramelmElementBase
paramtagnamesstr
= ()

new_autoshape_sp

funcnew_autoshape_sp(id_: int, name: str, prst: str, left: int, top: int, width: int, height: int) -> CT_Shape

Return a new p:sp element tree configured as a base auto shape.

paramid_int
paramnamestr
paramprststr
paramleftint
paramtopint
paramwidthint
paramheightint

Returns

pptx.oxml.shapes.autoshape.CT_Shape

new_freeform_sp

funcnew_freeform_sp(shape_id: int, name: str, x: int, y: int, cx: int, cy: int)

Return new p:sp element tree configured as freeform shape.

The returned shape has a a:custGeom subtree but no paths in its path list.

paramshape_idint
paramnamestr
paramxint
paramyint
paramcxint
paramcyint

new_placeholder_sp

funcnew_placeholder_sp(id_: int, name: str, ph_type: PP_PLACEHOLDER, orient: str, sz, idx) -> CT_Shape

Return a new p:sp element tree configured as a placeholder shape.

paramid_int
paramnamestr
paramph_typePP_PLACEHOLDER
paramorientstr
paramsz
paramidx

Returns

pptx.oxml.shapes.autoshape.CT_Shape

new_textbox_sp

funcnew_textbox_sp(id_, name, left, top, width, height)

Return a new p:sp element tree configured as a base textbox shape.

paramid_
paramname
paramleft
paramtop
paramwidth
paramheight

remove_all

funcremove_all(*tagnames: str) -> None

Remove child elements with tagname (e.g. "a:p") in tagnames.

paramtagnamesstr
= ()

Returns

None

xpath

funcxpath(xpath_str: str) -> Any

Override of lxml _Element.xpath() method.

Provides standard Open XML namespace mapping (nsmap) in centralized location.

paramxpath_strstr

Returns

typing.Any

On this page