CT_Shape
paper-pptx 0.2.0 API reference
p:sp custom element class.
Attributes
cx
attributecxLengthcy
attributecyLengthflipH
attributeflipHflipV
attributeflipVget_or_add_txBody
attributeget_or_add_txBodyCallable[[], CT_TextBody]has_custom_geometry
attributehas_custom_geometryTrue 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_elmTrue if this shape element has a p:ph descendant, indicating it
is a placeholder shape. False otherwise.
is_autoshape
attributeis_autoshapeTrue 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_textboxTrue 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
attributelna:ln grand-child element or None if not present.
nvSpPr
attributenvSpPrCT_ShapeNonVisual= OneAndOnlyOne('p:nvSpPr')ph
attributephCT_Placeholder | NoneThe p:ph descendant element if there is one, None otherwise.
ph_idx
attributeph_idxintInteger value of placeholder idx attribute.
Raises ValueError if shape is not a placeholder.
ph_orient
attributeph_orientstrPlaceholder orientation, e.g. 'vert'.
Raises ValueError if shape is not a placeholder.
ph_sz
attributeph_szstrPlaceholder size, e.g. ST_PlaceholderSize.HALF.
Raises ValueError if shape is not a placeholder.
ph_type
attributeph_typePlaceholder type, e.g. ST_PlaceholderType.TITLE ('title').
Raises ValueError if shape is not a placeholder.
prst
attributeprstValue of prst attribute of a:prstGeom element or None if not present.
prstGeom
attributeprstGeomCT_PresetGeometry2DReference to a:prstGeom child element.
None if this shape doesn't have one, for example, if it's a placeholder shape.
rot
attributerotfloatFloat representing degrees this shape is rotated clockwise.
shape_id
attributeshape_idInteger id of this shape
shape_name
attributeshape_nameName of this shape
spPr
attributespPrCT_ShapeProperties= OneAndOnlyOne('p:spPr')txBody
attributetxBodyCT_TextBody | None= ZeroOrOne('p:txBody', successors=('p:extLst',))x
attributexLengthxfrm
attributexfrmThe 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
attributexmlstrXML string for this element, suitable for testing purposes.
Pretty printed for readability and without an XML declaration at the top.
y
attributeyLengthFunctions
add_path
funcadd_path(w: Length, h: Length) -> CT_Path2DparamwLengthparamhLengthReturns
pptx.oxml.shapes.autoshape.CT_Path2Dfirst_child_found_in
funcfirst_child_found_in(*tagnames: str) -> _Element | NoneFirst child with tag in tagnames, or None if not found.
paramtagnamesstr= ()Returns
lxml.etree._Element | Noneget_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)paramelmElementBaseparamtagnamesstr= ()new_autoshape_sp
funcnew_autoshape_sp(id_: int, name: str, prst: str, left: int, top: int, width: int, height: int) -> CT_ShapeReturn a new p:sp element tree configured as a base auto shape.
paramid_intparamnamestrparamprststrparamleftintparamtopintparamwidthintparamheightintReturns
pptx.oxml.shapes.autoshape.CT_Shapenew_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_idintparamnamestrparamxintparamyintparamcxintparamcyintnew_placeholder_sp
funcnew_placeholder_sp(id_: int, name: str, ph_type: PP_PLACEHOLDER, orient: str, sz, idx) -> CT_ShapeReturn a new p:sp element tree configured as a placeholder shape.
paramid_intparamnamestrparamph_typePP_PLACEHOLDERparamorientstrparamszparamidxReturns
pptx.oxml.shapes.autoshape.CT_Shapenew_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_paramnameparamleftparamtopparamwidthparamheightremove_all
funcremove_all(*tagnames: str) -> NoneRemove child elements with tagname (e.g. "a:p") in tagnames.
paramtagnamesstr= ()Returns
Nonexpath
funcxpath(xpath_str: str) -> AnyOverride of lxml _Element.xpath() method.
Provides standard Open XML namespace mapping (nsmap) in centralized location.
paramxpath_strstrReturns
typing.Any