如何使用pptxpython库更改标题位置?

2024-04-25 17:28:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将标题为的文本框从幻灯片组的中心移动到顶部。我无法为我的脚本找到正确的参数。以下是与之相关的几行文字:

#setting slide type "Title and Content"
title_only_layout = pptx.slide_layouts[1]

#Adding content into the title box
pptx.slides.add_slide(title_only_layout)
pptx.slides[idx].shapes.title.text = "I am a title!"

这些命令将标题框添加到面板的中心。如何调整此脚本?你知道吗


Tags: 脚本标题only参数titletype中心setting
1条回答
网友
1楼 · 发布于 2024-04-25 17:28:18

作为蒂姆。卢卡斯提到,幻灯片标题是一个占位符,它的形状与其他形状类似,因为它具有.left.top.widthheight属性,您可以设置这些属性来定位和调整对象的大小。你知道吗

from pptx.util import Cm

title = slide.shapes.title
title.top = Cm(3)
# ... and likewise for other position and size attributes

相关问题 更多 >