scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.35k stars 510 forks source link

`MSO_SHAPE_TYPE.TEXT_BOX` creates a `smileyFace` #814

Open TenchiMuyo1984 opened 2 years ago

TenchiMuyo1984 commented 2 years ago

Version I've used:

I don't know if I'd made something wrong, but there is a thing I don't understand.

When I use MSO_SHAPE_TYPE.TEXT_BOX from from pptx.enum.shapes import MSO_SHAPE_TYPE I got a smiley instead of a textbox.

Here my code

from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE
from pptx.util import Inches

prs = Presentation()
title_only_slide_layout = prs.slide_layouts[5]
slide = prs.slides.add_slide(title_only_slide_layout)
shapes = slide.shapes

left   = Inches(0.93)  # 0.93" centers this overall set of shapes
top    = Inches(3.0)
width  = Inches(1.75)
height = Inches(1.0)

shape = shapes.add_shape(MSO_SHAPE_TYPE.TEXT_BOX, left, top, width, height)

prs.save('test.pptx')

The code based on the example from here: https://python-pptx.readthedocs.io/en/latest/user/quickstart.html#add-shape-example

I've analysed the elements inside of the .pptx file: Here is the element:

                <p:nvSpPr>
                    <p:cNvPr id="3" name="Smiley Face 2"/>
                    <p:cNvSpPr/>
                    <p:nvPr/>
                </p:nvSpPr>
                <p:spPr>
                    <a:xfrm>
                        <a:off x="850392" y="2743200"/>
                        <a:ext cx="1600200" cy="914400"/>
                    </a:xfrm>
                    <a:prstGeom prst="smileyFace">
                        <a:avLst/>
                    </a:prstGeom>
                </p:spPr>

The element is called smileyFace.

The result I got in powerpoint:

pptx_bug