【发布时间】:2019-01-04 06:24:05
【问题描述】:
我正在尝试使用 Python 中的 python-pptx 模块创建一些形状。
我已经创建了形状,但是我无法编辑形状内文本的字体颜色。默认情况下,它以白色显示。我正在尝试查看如何更改文本颜色。以下是我迄今为止所构建的:
left = Inches(1.0)
top = Inches(3.9)
width = Inches(1.2)
height = Inches(2.5)
shape = shapes.add_shape(
MSO_SHAPE.RECTANGLE, left, top, width, height
)
fill = shape.fill
fill.solid()
fill.fore_color.rgb = RGBColor(226, 206, 72) # This RGB code is the background color that I want the shape to be in
fill.fore_color.brightness = -0.3
text_frame = shape.text_frame
text_frame.clear()
p = text_frame.paragraphs[0]
run = p.add_run()
run.text = 'Test message'
font = run.font
font.name = 'Arial'
font.size = Pt(16)
font.bold = True
【问题讨论】:
标签: python python-pptx