如何解决分组自选图形并将其放置在PowerPoint python-pptx中
我试图在幻灯片中找到自动形状并将其添加到组中。然后将它们相对于自己定位。我怎样才能做到这一点 ?我的代码示例如下:
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE
from pptx.enum.text import MSO_ANCHOR,MSO_AUTO_SIZE
from pptx.enum.text import PP_ALIGN
from pptx.util import Inches,Mm,Pt
from pptx.dml.color import RGBColor
from pptx.oxml.shapes.groupshape import CT_GroupShape
from pptx.enum.text import PP_ALIGN
import os
prs = Presentation()
title_only_slide_layout = prs.slide_layouts[5]
slide = prs.slides.add_slide(title_only_slide_layout)
shapes = slide.shapes
top = Inches(2.0)
left = Inches(2.0)
width = Inches(2.0)
height = Inches(2.0)
for i in range(0,6):
shape = shapes.add_shape(MSO_SHAPE.RECTANGLE,left,top,width,height)
prs.shapes.shapetree.GroupShapes.add_group_shape(shape(i))
#text regulations inside slots
shape.text_frame.text = str(i+1)
text_frame = shape.text_frame
text_frame.margin_bottom = Mm(1)
text_frame.margin_left = Inches(1)
text_frame.word_wrap = False
text_frame.auto_size = MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT
prs.save("new.pptx")
os.startfile("new.pptx")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。