CT_GroupShape
paper-pptx 0.2.0 API reference
Used for shape tree (p:spTree) as well as the group shape (p:grpSp) elements.
Attributes
chExt
attributechExtDescendent p:grpSpPr/a:xfrm/a:chExt element.
chOff
attributechOffDescendent p:grpSpPr/a:xfrm/a:chOff element.
cx
attributecxLengthcy
attributecyLengthflipH
attributeflipHflipV
attributeflipVgrpSpPr
attributegrpSpPrCT_GroupShapeProperties= OneAndOnlyOne('p:grpSpPr')has_ph_elm
attributehas_ph_elmTrue if this shape element has a p:ph descendant, indicating it
is a placeholder shape. False otherwise.
max_shape_id
attributemax_shape_idintMaximum int value assigned as @id in this slide.
This is generally a shape-id, but ids can be assigned to other objects so we just check all @id values anywhere in the document (XML id-values have document scope).
In practice, its minimum value is 1 because the spTree element itself is always assigned id="1".
nvGrpSpPr
attributenvGrpSpPrCT_GroupShapeNonVisual= OneAndOnlyOne('p:nvGrpSpPr')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.
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_ShapePropertiestxBody
attributetxBodyChild p:txBody element, None if not present.
x
attributexLengthxfrm
attributexfrmCT_Transform2D | NoneThe a:xfrm grandchild element or None if not found.
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_autoshape
funcadd_autoshape(id_: int, name: str, prst: str, x: int, y: int, cx: int, cy: int) -> CT_ShapeReturn new p:sp appended to the group/shapetree with specified attributes.
paramid_intparamnamestrparamprststrparamxintparamyintparamcxintparamcyintReturns
pptx.oxml.shapes.autoshape.CT_Shapeadd_cxnSp
funcadd_cxnSp(id_: int, name: str, type_member: MSO_CONNECTOR_TYPE, x: int, y: int, cx: int, cy: int, flipH: bool, flipV: bool) -> CT_ConnectorReturn new p:cxnSp appended to the group/shapetree with the specified attribues.
paramid_intparamnamestrparamtype_memberMSO_CONNECTOR_TYPEparamxintparamyintparamcxintparamcyintparamflipHboolparamflipVboolReturns
pptx.oxml.shapes.connector.CT_Connectoradd_freeform_sp
funcadd_freeform_sp(x: int, y: int, cx: int, cy: int) -> CT_ShapeAppend a new freeform p:sp with specified position and size.
paramxintparamyintparamcxintparamcyintReturns
pptx.oxml.shapes.autoshape.CT_Shapeadd_grpSp
funcadd_grpSp() -> CT_GroupShapeReturn p:grpSp element newly appended to this shape tree.
The element contains no sub-shapes, is positioned at (0, 0), and has width and height of zero.
Returns
pptx.oxml.shapes.groupshape.CT_GroupShapeadd_pic
funcadd_pic(id_: int, name: str, desc: str, rId: str, x: int, y: int, cx: int, cy: int) -> CT_PictureAppend a p:pic shape to the group/shapetree having properties as specified in call.
paramid_intparamnamestrparamdescstrparamrIdstrparamxintparamyintparamcxintparamcyintReturns
pptx.oxml.shapes.picture.CT_Pictureadd_placeholder
funcadd_placeholder(id_: int, name: str, ph_type: PP_PLACEHOLDER, orient: str, sz: str, idx: int) -> CT_ShapeAppend a newly-created placeholder p:sp shape having the specified properties.
paramid_intparamnamestrparamph_typePP_PLACEHOLDERparamorientstrparamszstrparamidxintReturns
pptx.oxml.shapes.autoshape.CT_Shapeadd_table
funcadd_table(id_: int, name: str, rows: int, cols: int, x: int, y: int, cx: int, cy: int) -> CT_GraphicalObjectFrameAppend a p:graphicFrame shape containing a table as specified in call.
paramid_intparamnamestrparamrowsintparamcolsintparamxintparamyintparamcxintparamcyintReturns
pptx.oxml.shapes.graphfrm.CT_GraphicalObjectFrameadd_textbox
funcadd_textbox(id_: int, name: str, x: int, y: int, cx: int, cy: int) -> CT_ShapeAppend a newly-created textbox p:sp shape having the specified position and size.
paramid_intparamnamestrparamxintparamyintparamcxintparamcyintReturns
pptx.oxml.shapes.autoshape.CT_Shapefirst_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_xfrm
funcget_or_add_xfrm() -> CT_Transform2DReturn the a:xfrm grandchild element, newly-added if not present.
Returns
pptx.oxml.shapes.shared.CT_Transform2Dinsert_element_before
funcinsert_element_before(elm: ElementBase, *tagnames: str)paramelmElementBaseparamtagnamesstr= ()iter_ph_elms
funciter_ph_elms()Generate each placeholder shape child element in document order.
iter_shape_elms
funciter_shape_elms() -> Iterator[ShapeElement]Generate each child of this p:spTree element that corresponds to a shape.
Items appear in XML document order.
Returns
typing.Iterator[pptx.oxml.shapes.ShapeElement]new_grpSp
funcnew_grpSp(id_: int, name: str) -> CT_GroupShapeReturn new "loose" p:grpSp element having id_ and name.
paramid_intparamnamestrReturns
pptx.oxml.shapes.groupshape.CT_GroupShaperecalculate_extents
funcrecalculate_extents() -> NoneAdjust x, y, cx, and cy to incorporate all contained shapes.
This would typically be called when a contained shape is added, removed, or its position or size updated.
This method is recursive "upwards" since a change in a group shape can change the position and size of its containing group.
Returns
Noneremove_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