| name | pptx-generator |
| description | 专业PPT生成器。Use when user wants to create editable PowerPoint presentations with professional layouts, multiple styles, and beautiful designs. Supports business, academic, creative styles. 可编辑PPT、幻灯片制作、演示文稿。 |
| version | 1.0.1 |
| license | MIT-0 |
| metadata | {"openclaw":{"emoji":"📊","requires":{"bins":"[Truncated]","env":"[Truncated]"}}} |
| dependencies | pip install python-pptx pillow |
PPT Generator
专业PPT生成器,创建可编辑、排版精美、多风格的PowerPoint演示文稿。
Features
- 📊 可编辑PPTX: 标准Office格式,可二次编辑
- 🎨 多种风格: 商务、学术、创意、简约
- 📐 精美排版: 专业布局,字体层次清晰
- 📈 图表支持: 柱状图、折线图、饼图
- 🖼️ 图片支持: 插入图片,自动排版
- 📝 专业模板: 10+预制模板
支持的风格
| 风格 | 适用场景 | 特点 |
|---|
| 商务蓝 | 商业汇报 | 专业、稳重 |
| 学术白 | 学术论文 | 简洁、规范 |
| 创意紫 | 创意展示 | 时尚、活力 |
| 科技深 | 技术分享 | 现代、高端 |
| 极简灰 | 通用场景 | 简约、百搭 |
使用方式
User: "帮我做一个关于AI发展的PPT"
User: "生成商务风格的项目汇报PPT"
User: "做一个学术论文答辩PPT"
Python代码实现
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE
class PPTGenerator:
def __init__(self, style='business_blue'):
self.prs = Presentation()
self.style = style
self.colors = self._get_colors(style)
self.fonts = self._get_fonts()
def _get_colors(self, style):
"""获取配色方案"""
schemes = {
'business_blue': {
'primary': RGBColor(30, 60, 114),
'secondary': RGBColor(70, 130, 180),
'accent': RGBColor(255, 193, 7),
'text': RGBColor(51, 51, 51),
'bg': RGBColor(255, 255, 255)
},
'academic_white': {
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , )
},
: {
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , )
},
: {
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , )
},
: {
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , ),
: RGBColor(, , )
}
}
schemes.get(style, schemes[])
():
{
: ,
: ,
:
}
():
slide = .prs.slides.add_slide(.prs.slide_layouts[])
._set_slide_bg(slide, .colors[])
left, top, width, height = Inches(), Inches(), Inches(), Inches()
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
tf.word_wrap =
p = tf.paragraphs[]
p.text = title
p.font.size = Pt()
p.font.bold =
p.font.color.rgb = .colors[]
p.alignment = PP_ALIGN.CENTER
subtitle:
p2 = tf.add_paragraph()
p2.text = subtitle
p2.font.size = Pt()
p2.font.color.rgb = .colors[]
p2.alignment = PP_ALIGN.CENTER
p2.space_before = Pt()
slide
():
slide = .prs.slides.add_slide(.prs.slide_layouts[])
._set_slide_bg(slide, .colors[])
._add_title_bar(slide, title)
left, top, width, height = Inches(), Inches(), Inches(), Inches()
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
tf.word_wrap =
i, bullet (bullets):
p = tf.paragraphs[] i == tf.add_paragraph()
p.text =
p.font.size = Pt()
p.font.color.rgb = .colors[]
p.space_after = Pt()
slide
():
slide = .prs.slides.add_slide(.prs.slide_layouts[])
._set_slide_bg(slide, .colors[])
._add_title_bar(slide, title)
left_box = slide.shapes.add_textbox(Inches(), Inches(), Inches(), Inches())
left_tf = left_box.text_frame
left_tf.word_wrap =
i, item (left_content):
p = left_tf.paragraphs[] i == left_tf.add_paragraph()
p.text =
p.font.size = Pt()
p.font.color.rgb = .colors[]
p.space_after = Pt()
right_box = slide.shapes.add_textbox(Inches(), Inches(), Inches(), Inches())
right_tf = right_box.text_frame
right_tf.word_wrap =
i, item (right_content):
p = right_tf.paragraphs[] i == right_tf.add_paragraph()
p.text =
p.font.size = Pt()
p.font.color.rgb = .colors[]
p.space_after = Pt()
slide
():
slide = .prs.slides.add_slide(.prs.slide_layouts[])
._set_slide_bg(slide, .colors[])
._add_title_bar(slide, title)
rows_count = (rows) +
cols_count = (headers)
left, top = Inches(), Inches()
width, height = Inches(), Inches()
table_shape = slide.shapes.add_table(rows_count, cols_count, left, top, width, height)
table = table_shape.table
i, header (headers):
cell = table.cell(, i)
cell.text = header
cell.fill.solid()
cell.fill.fore_color.rgb = .colors[]
paragraph cell.text_frame.paragraphs:
paragraph.font.size = Pt()
paragraph.font.bold =
paragraph.font.color.rgb = RGBColor(, , )
paragraph.alignment = PP_ALIGN.CENTER
row_idx, row (rows, ):
col_idx, cell_text (row):
cell = table.cell(row_idx, col_idx)
cell.text = (cell_text)
paragraph cell.text_frame.paragraphs:
paragraph.font.size = Pt()
paragraph.font.color.rgb = .colors[]
paragraph.alignment = PP_ALIGN.CENTER
slide
():
slide = .prs.slides.add_slide(.prs.slide_layouts[])
._set_slide_bg(slide, .colors[])
._add_title_bar(slide, title)
left, top, width, height = Inches(), Inches(), Inches(), Inches()
slide.shapes.add_picture(image_path, left, top, width, height)
caption:
txBox = slide.shapes.add_textbox(Inches(), Inches(), Inches(), Inches())
tf = txBox.text_frame
p = tf.paragraphs[]
p.text = caption
p.font.size = Pt()
p.font.color.rgb = .colors[]
p.alignment = PP_ALIGN.CENTER
slide
():
slide = .prs.slides.add_slide(.prs.slide_layouts[])
._set_slide_bg(slide, .colors[])
._add_title_bar(slide, title)
txBox = slide.shapes.add_textbox(Inches(), Inches(), Inches(), Inches())
tf = txBox.text_frame
tf.word_wrap =
i, point (points):
p = tf.paragraphs[] i == tf.add_paragraph()
p.text =
p.font.size = Pt()
p.font.color.rgb = .colors[]
p.space_after = Pt()
conclusion_box = slide.shapes.add_shape(
MSO_SHAPE.ROUNDED_RECTANGLE,
Inches(), Inches(), Inches(), Inches()
)
conclusion_box.fill.solid()
conclusion_box.fill.fore_color.rgb = .colors[]
tf2 = conclusion_box.text_frame
tf2.word_wrap =
p2 = tf2.paragraphs[]
p2.text =
p2.font.size = Pt()
p2.font.color.rgb = RGBColor(, , )
p2.alignment = PP_ALIGN.CENTER
slide
():
background = slide.background
fill = background.fill
fill.solid()
fill.fore_color.rgb = color
():
title_bar = slide.shapes.add_shape(
MSO_SHAPE.RECTANGLE,
Inches(), Inches(), Inches(), Inches()
)
title_bar.fill.solid()
title_bar.fill.fore_color.rgb = .colors[]
title_bar.line.fill.background()
txBox = slide.shapes.add_textbox(Inches(), Inches(), Inches(), Inches())
tf = txBox.text_frame
p = tf.paragraphs[]
p.text = title
p.font.size = Pt()
p.font.bold =
p.font.color.rgb = RGBColor(, , )
p.alignment = PP_ALIGN.LEFT
():
.prs.save(output_path)
output_path
gen = PPTGenerator(style=)
gen.add_title_slide(, )
gen.add_content_slide(, [
,
,
])
gen.add_table_slide(,
[, , , ],
[
[, , , ],
[, , , ],
[, , , ]
]
)
gen.add_summary_slide(, [
,
,
], )
gen.save()
使用场景
User: "做一个20页的AI行业报告PPT,商务风格"
Agent: 使用 PPTGenerator(style='business_blue') 生成
User: "做一个学术答辩PPT"
Agent: 使用 PPTGenerator(style='academic_white') 生成
User: "做一个技术分享PPT,科技风格"
Agent: 使用 PPTGenerator(style='tech_dark') 生成
Notes
- 生成标准.pptx格式,可编辑
- 支持Microsoft PowerPoint、WPS、LibreOffice
- 字体自动适配系统
- 支持中英文