首页 > 解决方案 > 控制ROUNDED_RECTANGLE的圆角,python + pptx

问题描述

在幻灯片上添加 ROUNDED_RECTANGLE 时,通过使用 pptx,我有下面的行并生成了一张幻灯片。

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

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

shape = shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(1), Inches(0.5), Inches(8), Inches(2))

prs.save('c:\\PPT\\round rectangle.pptx')

如果是手动的,可以调整圆角(红色箭头指向的地方)。

有没有办法从脚本中控制它?谢谢你。

在此处输入图像描述

标签: pythonpowerpointpython-pptx

解决方案


像这样的形状有一个或多个 .Adjustments 属性。

你需要修改 .Adjustments(1) ,我记得它可以取 0 到 1 之间的值。例如,值 0.5 会将黄色调整菱形移动 0.5,即角与形状中点之间的距离。


推荐阅读