如何使用 pptx-python 库更改标题位置?

How to change Title position using pptx-python library?

我正在尝试将带有标题的文本框从中间移到幻灯片的顶部。我无法为我的脚本找到正确的参数。以下是与之相关的一些行:

#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!"

这些命令将标题框添加到卡片组的中央。我该如何调整这个脚本?

如 Tim.Lucas 所述,幻灯片标题是一个占位符,其形状与其他任何形状一样,具有 .left.top.width 和.height 属性,您可以将其设置为 object.

的位置和大小
from pptx.util import Cm

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