Skip to content

Commit b4ad3bb

Browse files
committed
Merge pull request #9 from hoopes/cust_geom_in_groupshape
added custom geom stuff to the group shape stuff
2 parents a4653c2 + e60dd63 commit b4ad3bb

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

pptx/oxml/shapes/groupshape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def add_custom_geometry(self, id_, name, left, top, width, height):
8383
position and size.
8484
"""
8585
sp = CT_Shape.new_custom_geometry_sp(id_, name, left, top, width, height)
86-
self.insert_element_before(sp, 'p:extList')
86+
self.insert_element_before(sp, 'p:extLst')
8787
return sp
8888

8989
def add_groupshape(self, id_, name, x, y, cx, cy):

pptx/shapes/groupshape.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ def add_textbox(self, left, top, width, height):
170170
textbox = self._shape_factory(sp)
171171
return textbox
172172

173+
def add_custom_geometry(self, left, top, width, height):
174+
"""
175+
Add a custom geometry shpane of specified size at specified position
176+
on slide.
177+
"""
178+
sp = self._add_cust_geom_sp(left, top, width, height)
179+
cust_geom = self._shape_factory(sp)
180+
return cust_geom
181+
182+
def add_groupshape(self, left, top, width, height):
183+
"""
184+
Add groupshape of specified size at specified position on slide.
185+
"""
186+
sp = self._add_groupshape_sp(left, top, width, height)
187+
groupshape = self._shape_factory(sp)
188+
return groupshape
189+
173190
def clone_layout_placeholders(self, slide_layout):
174191
"""
175192
Add placeholder shapes based on those in *slide_layout*. Z-order of
@@ -284,6 +301,24 @@ def _add_textbox_sp(self, x, y, cx, cy):
284301
sp = self._grpSp.add_textbox(id_, name, x, y, cx, cy)
285302
return sp
286303

304+
def _add_cust_geom_sp(self, x, y, cx, cy):
305+
"""
306+
Return a newly-added custom geometry ``<p:sp>`` element
307+
"""
308+
id_ = self._next_shape_id
309+
name = 'CustGeom %s' % id_
310+
sp = self._grpSp.add_custom_geometry(id_, name, x, y, cx, cy)
311+
return sp
312+
313+
def _add_groupshape_sp(self, x, y, cx, cy):
314+
"""
315+
316+
"""
317+
id_ = self._next_shape_id
318+
name = 'GroupShape %d' % (id_-1)
319+
sp = self._grpSp.add_groupshape(id_, name, x, y, cx, cy)
320+
return sp
321+
287322
def _clone_layout_placeholder(self, layout_placeholder):
288323
"""
289324
Add a new placeholder shape based on the slide layout placeholder

0 commit comments

Comments
 (0)