python - 使用 python-pptx 设置主题

标签 python python-pptx

PowerPoint 有可供选择的主题。选择是这样的:

有没有办法使用python-pptx设置新演示文稿的主题?

类似于:

from pptx import Presentation

prs = Presentation()
prs.set_theme(theme)
...

关于this github issue它建议创建一个带有主题的幻灯片,然后打开它。

In that starting .pptx file you would include your customized themes. You can do this by creating a presentation that uses all the themes you would like to have available and then deleting all the slides (but not the slide masters or slide layouts). You will be left with an empty presentation having multiple slide masters, each of which has its own set of slide layouts.

最佳答案

基本上,您可以使用该主题创建一个模板,并将其用作起点(而不是内置的默认主题)。

  1. 在 PowerPoint 中打开一个具有所需主题的新演示文稿。
  2. 将其另存为 .pptx,并使用您想要的名称,也许 madison.pptx 是屏幕截图中顶行的第三个。
  3. 创建新演示文稿时使用该演示文稿作为“起点”:

    prs = Presentation("madison.pptx")
    

新演示文稿 (prs) 将应用 Madison 主题。

python-pptx 尚无法将主题应用到现有演示文稿。

关于python - 使用 python-pptx 设置主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57482998/

相关文章:

python - 如何使用 python-pptx 删除未填充的占位符项目

python - 父子关系可视化、模式匹配和全文搜索

Python 字典 "copy value"

python PPTX : Adding Entire Slide from Another Presentation

python-pptx:将图片插入内容占位符

python - python-pptx中insert_table的表格高度

具有副作用的 Python 补丁对象

Python 提高函数速度

python - 帮助避免 python/django 错误的工具或技术

python-pptx 访问类别轴元素 "tickLblSkip"& "tickMarkSkip"