在for循环最后一行设置字体样式的时候,报错
from pptx import Presentation
from pptx.enum.shapes import MSO_AUTO_SHAPE_TYPE
from pptx.util import Pt
def create_shape():
# 创建PPT文件
ppt = Presentation()
# 创建一个幻灯片
slide = ppt.slides.add_slide(ppt.slide_layouts[5])
# 获取形状对象
shapes = slide.shapes
shapes.title.text= '流程图'
# 增加图形
'''
TypeError: _BaseGroupShapes.add_shape() missing 4 required positional arguments: 'left', 'top', 'width', and 'height'
'''
left = Pt(100)
top = Pt(200)
width = Pt(100)
height = Pt(30)
tmp_shape = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.PENTAGON,left,top,width,height)
tmp_shape.text = '第1步'
for i in range(2,5):
left = left + width -Pt(10)
ts = shapes.add_shape(MSO_AUTO_SHAPE_TYPE.CHEVRON,left,top,width,height)
frame = ts.text_frame
frame.text = f'第{i}步'
frame.fit_text(max_size = 10,bold = True,italic = True)
# 保存PPT文件
ppt.save('./auto_ppt/create_data/04_增加图形.pptx')
if __name__ == '__main__':
create_shape()