简体   繁体   English

如何在python pptx中更改标题颜色

[英]how to change title color in python pptx

from pptx import Presentation
from pptx.dml.color import RGBColor
prs=Presentation()
title_slide_layout=prs.slide_layouts[0]
slide=prs.slides.add_slide(title_slide_layout)
background=slide.background
fill = background.fill
fill.solid()
fill.fore_color.rgb = RGBColor(59, 89, 152)
title=slide.shapes.title
subtitle=slide.placeholders[1]
title.text="title"
subtitle.text="Subtitle"
prs.save('mynewone.pptx')

i tired to change the same i changed the backgroud but i dint work 我累了要改变相同的东西,我改变了背景,但我努力工作

You need to handle the shape's text_frame property and apply that font formatting to the paragraphs . 您需要处理形状的text_frame属性,并将该字体格式应用于paragraphs I think this should work, according to the documentation : 根据文档 ,我认为这应该可行:

title.text_frame.paragraphs[0].font.color.rgb = RGBColor(59,89, 152)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM