PPT 主题颜色解释(Theme Color Scheme)

每个 PPTX 文件包含一个主题文件:

复制代码

ppt/theme/theme1.xml

其中定义了 12 种主题颜色:

名称 含义
bg1 Background 1
tx1 Text 1
bg2 Background 2
tx2 Text 2
accent1 强调色 1
accent2 强调色 2
accent3 强调色 3
accent4 强调色 4
accent5 强调色 5
accent6 强调色 6
hlink 超链接颜色
folHlink 访问过的超链接

accent6 就是 PPT 主题的第六个强调色。

不同模板 RGB 会不同。


🔍 如何获取 accent6 的 RGB 颜色?

Python-pptx 不支持直接取 theme 色的 RGB,需要解析 XML:

代码:读取主题颜色(精准版)

复制代码
复制代码
from pptx import Presentation
from lxml import etree

def get_theme_colors(ppt_path):
    prs = Presentation(ppt_path)
    theme_part = prs.part.theme.part
    xml = etree.fromstring(theme_part.blob)

    ns = {"a": "http://schemas.openxmlformats.org/drawingml/2006/main"}

    colors = {}
    scheme_clrs = xml.xpath("//a:themeElements/a:clrScheme/*", namespaces=ns)

    for clr in scheme_clrs:
        name = clr.tag.split("}")[-1]  # accent1, accent2...
        rgb = None

        srgbClr = clr.find("a:srgbClr", ns)
        if srgbClr is not None:
            rgb = srgbClr.get("val")

        colors[name] = rgb

    return colors

print(get_theme_colors("你的PPT路径.pptx"))

返回示例:

复制代码
复制代码
{
  'accent1': '4472C4',
  'accent6': '70AD47',
  'bg1': 'FFFFFF',
  ...
}
相关推荐
chatexcel1 天前
AI PPT生成学术展演文稿实操教程:提示词设计与生成流程详解
人工智能·powerpoint
Westward-sun.1 天前
Codex + Image Gen 制作论文答辩 PPT
人工智能·深度学习·powerpoint
IT策士1 天前
Python PPT操作:从入门到精通
开发语言·python·powerpoint
chatexcel2 天前
ChatExcel AIPPT实测:基于Excel数据生成PPT,覆盖图表可视化与办公汇报
信息可视化·powerpoint·excel
Mr数据杨3 天前
【Codex】用PPT文案额外描述优化课件生成细节
java·javascript·django·powerpoint·codex·项目开发
刘欣的博客3 天前
检测PowerPoint是否进入了PPT全屏放映模式
powerpoint·监控ppt全屏模式
王up1653 天前
反转课堂从作业开始!PPT内置作业管理工具,课代表扛活、学生自评,老师终于能闲下来啦!
powerpoint·教育·作业管理·班级管理
是筱倩阿3 天前
Python 编程实现 PPT 批量转图片(PNG/JPG)
python·opencv·powerpoint
kyriewen113 天前
你的前端滤镜慢得像PPT?用Rust+WebAssembly,一秒处理4K图
开发语言·前端·javascript·设计模式·rust·ecmascript·powerpoint
Mr数据杨4 天前
【Codex】用整合教案模块串联PPT文案与课堂教学方案
django·powerpoint·codex·项目开发