python-pptx - 在“标题和内容”幻灯片中添加内容框

问题描述 投票:0回答:1

我正在使用 pptx 模块创建 PowerPoint“标题和内容”幻灯片。

prs = Presentation()
mySlide = prs.slides.add_slide(prs.slide_layouts[1])

我可以使用“title”属性或“placeholder[0]”属性来“寻址”标题。

# These both work.
titlePlaceholder = mySlide.shapes.title
titlePlaceholder = mySlide.shapes.placeholders[0]

但是,我能找到“解决”“标题和内容”幻灯片上的“内容框”的唯一方法是使用“占位符[1]”属性。

contentPlaceholder = mySlide.shapes.placeholders[1]

还有另一种方法来“解决”内容框吗?有类似“内容”属性的东西吗?

# I'd like to use something similar to this.
contentPlaceholder = mySlide.shapes.content

顺便说一句,对于我的代码示例中的任何拼写错误,我提前表示歉意。出于公司原因,我无法在进行 Python 编程的同一系统上访问 StackOverflow,因此无法剪切和粘贴。

python powerpoint python-pptx
1个回答
0
投票

没有。你必须通过排除法来做到这一点。在我的代码中,我选择标题后的第一个 - 尽管有时我选择使用该标题作为副标题。

© www.soinside.com 2019 - 2024. All rights reserved.