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',
  ...
}
相关推荐
dingxingdi3 天前
AI PPT 制作流程
人工智能·powerpoint
小真zzz5 天前
2026年免费AI PPT工具深度评测:多款实用工具推荐
人工智能·搜索引擎·ai·powerpoint·ppt
神码观察9 天前
WorkBuddy高效制作PPT与交互式课件实操指南
powerpoint
SpaceAIGlobal10 天前
医护人员使用AI生成PPT:如何保证原始数据不被篡改?
人工智能·powerpoint
cyhysr11 天前
Python读取ppt文本转存txt
python·powerpoint
A懿轩A11 天前
【NotebookLM 使用教程】 Slides 指令库:11套通用PPT风格Prompt(含中英文对照)
python·prompt·powerpoint·ppt·notebooklm
百事牛科技11 天前
高效办公技巧:如何取消PPT以“只读方式”打开?
windows·powerpoint
aosky11 天前
可以白嫖的Nano Banana2 字节跳动出品可以写ppt,写网页,做设计....
人工智能·数据分析·powerpoint
xiami_world11 天前
AI生成PPT工具技术横评:Agent专家模式如何重构PPT生成工作流(6款工具实测)
人工智能·经验分享·ai·信息可视化·powerpoint
chatexcel12 天前
AI生成PPT工具哪个好?2026主流AIPPT工具实测对比
人工智能·powerpoint