Paper Office
paper-pptxAPI referenceoxml.shapes.groupshape

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

attributechExt

Descendent p:grpSpPr/a:xfrm/a:chExt element.

chOff

attributechOff

Descendent p:grpSpPr/a:xfrm/a:chOff element.

cx

attributecxLength

cy

attributecyLength

flipH

attributeflipH

flipV

attributeflipV

grpSpPr

attributegrpSpPrCT_GroupShapeProperties
= OneAndOnlyOne('p:grpSpPr')

has_ph_elm

attributehas_ph_elm

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

max_shape_id

attributemax_shape_idint

Maximum 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 | 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.

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

txBody

attributetxBody

Child p:txBody element, None if not present.

x

attributexLength

xfrm

attributexfrmCT_Transform2D | None

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

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_autoshape

funcadd_autoshape(id_: int, name: str, prst: str, x: int, y: int, cx: int, cy: int) -> CT_Shape

Return new p:sp appended to the group/shapetree with specified attributes.

paramid_int
paramnamestr
paramprststr
paramxint
paramyint
paramcxint
paramcyint

Returns

pptx.oxml.shapes.autoshape.CT_Shape

add_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_Connector

Return new p:cxnSp appended to the group/shapetree with the specified attribues.

paramid_int
paramnamestr
paramtype_memberMSO_CONNECTOR_TYPE
paramxint
paramyint
paramcxint
paramcyint
paramflipHbool
paramflipVbool

Returns

pptx.oxml.shapes.connector.CT_Connector

add_freeform_sp

funcadd_freeform_sp(x: int, y: int, cx: int, cy: int) -> CT_Shape

Append a new freeform p:sp with specified position and size.

paramxint
paramyint
paramcxint
paramcyint

Returns

pptx.oxml.shapes.autoshape.CT_Shape

add_grpSp

funcadd_grpSp() -> CT_GroupShape

Return 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_GroupShape

add_pic

funcadd_pic(id_: int, name: str, desc: str, rId: str, x: int, y: int, cx: int, cy: int) -> CT_Picture

Append a p:pic shape to the group/shapetree having properties as specified in call.

paramid_int
paramnamestr
paramdescstr
paramrIdstr
paramxint
paramyint
paramcxint
paramcyint

Returns

pptx.oxml.shapes.picture.CT_Picture

add_placeholder

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

Append a newly-created placeholder p:sp shape having the specified properties.

paramid_int
paramnamestr
paramph_typePP_PLACEHOLDER
paramorientstr
paramszstr
paramidxint

Returns

pptx.oxml.shapes.autoshape.CT_Shape

add_table

funcadd_table(id_: int, name: str, rows: int, cols: int, x: int, y: int, cx: int, cy: int) -> CT_GraphicalObjectFrame

Append a p:graphicFrame shape containing a table as specified in call.

paramid_int
paramnamestr
paramrowsint
paramcolsint
paramxint
paramyint
paramcxint
paramcyint

Returns

pptx.oxml.shapes.graphfrm.CT_GraphicalObjectFrame

add_textbox

funcadd_textbox(id_: int, name: str, x: int, y: int, cx: int, cy: int) -> CT_Shape

Append a newly-created textbox p:sp shape having the specified position and size.

paramid_int
paramnamestr
paramxint
paramyint
paramcxint
paramcyint

Returns

pptx.oxml.shapes.autoshape.CT_Shape

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_xfrm

funcget_or_add_xfrm() -> CT_Transform2D

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

Returns

pptx.oxml.shapes.shared.CT_Transform2D

insert_element_before

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

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_GroupShape

Return new "loose" p:grpSp element having id_ and name.

paramid_int
paramnamestr

Returns

pptx.oxml.shapes.groupshape.CT_GroupShape

recalculate_extents

funcrecalculate_extents() -> None

Adjust 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

None

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