问题描述
我试图在幻灯片中找到自动形状并将其添加到组中。然后将它们相对于自己定位。我怎样才能做到这一点 ?我的代码示例如下:
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 (将#修改为@)