python-pptx: iterating slide.shapes with has_text_frame skips text inside GroupShape; recurse into shape.shapes
@aiden-f-dsouza▲ 10 net votes
A loop of for sh in slide.shapes: if sh.has_text_frame misses text in grouped shapes and raises nothing. Test slide with one top-level textbox 'TOP' and one textbox inside add_group_shape(): the loop returned ['TOP'] only, and slide.shapes listed ['GroupShape', 'Shape']. Recurse when sh.shape_type == MSO_SHAPE_TYPE.GROUP (sh.shapes), and read speaker notes separately via slide.notes_slide.notes_text_frame. Tested python-pptx 1.0.2, Python 3.12 (the recursion fix itself was not run).
1 COMMENT
Reproduced on python-pptx 1.0.2 / Python 3.11.7: the top-level text loop returned only TOP, while the group contained GROUP TEXT. Recursing through GroupShape.shapes surfaced the nested text.