专业PPT生成器。Use when user wants to create editable PowerPoint presentations with professional layouts, multiple styles, and beautiful designs. Supports business, academic, creative styles. 可编辑PPT、幻灯片制作、演示文稿。
专业PPT生成器,创建可编辑、排版精美、多风格的PowerPoint演示文稿。
| 风格 | 适用场景 | 特点 |
|---|---|---|
| 商务蓝 | 商业汇报 | 专业、稳重 |
| 学术白 |
用户: 帮我做一个关于AI发展的PPT
用户: 生成商务风格的项目汇报PPT
用户: 做一个学术论文答辩PPT
python
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PPALIGN, MSOANCHOR
from pptx.enum.shapes import MSO_SHAPE
class PPTGenerator:
def init(self, style=business_blue):
self.prs = Presentation()
self.style = style
self.colors = self.getcolors(style)
self.fonts = self.getfonts()
def getcolors(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: {
primary: RGBColor(0, 51, 102),
secondary: RGBColor(102, 102, 102),
accent: RGBColor(204, 0, 0),
text: RGBColor(51, 51, 51),
bg: RGBColor(255, 255, 255)
},
creative_purple: {
primary: RGBColor(102, 45, 140),
secondary: RGBColor(155, 89, 182),
accent: RGBColor(241, 196, 15),
text: RGBColor(51, 51, 51),
bg: RGBColor(248, 248, 255)
},
tech_dark: {
primary: RGBColor(30, 30, 30),
secondary: RGBColor(60, 60, 60),
accent: RGBColor(0, 200, 150),
text: RGBColor(240, 240, 240),
bg: RGBColor(20, 20, 25)
},
minimal_gray: {
primary: RGBColor(80, 80, 80),
secondary: RGBColor(150, 150, 150),
accent: RGBColor(0, 120, 215),
text: RGBColor(51, 51, 51),
bg: RGBColor(250, 250, 250)
}
}
return schemes.get(style, schemes[business_blue])
def getfonts(self):
获取字体配置
return {
title: Arial,
body: Arial,
chinese: Microsoft YaHei
}
def addtitleslide(self, title, subtitle=):
添加封面页
slide = self.prs.slides.addslide(self.prs.slidelayouts[6])
# 背景色
self.setslide_bg(slide, self.colors[bg])
# 标题
left, top, width, height = Inches(1), Inches(2), Inches(8), Inches(2)
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
tf.word_wrap = True
p = tf.paragraphs[0]
p.text = title
p.font.size = Pt(44)
p.font.bold = True
p.font.color.rgb = self.colors[primary]
p.alignment = PP_ALIGN.CENTER
# 副标题
if subtitle:
p2 = tf.add_paragraph()
p2.text = subtitle
p2.font.size = Pt(20)
p2.font.color.rgb = self.colors[secondary]
p2.alignment = PP_ALIGN.CENTER
p2.space_before = Pt(20)
return slide
def addcontentslide(self, title, bullets, layout=left):
添加内容页
slide = self.prs.slides.addslide(self.prs.slidelayouts[6])
# 背景色
self.setslide_bg(slide, self.colors[bg])
# 标题栏
self.addtitle_bar(slide, title)
# 内容区域
left, top, width, height = Inches(0.8), Inches(1.5), Inches(8.4), Inches(5)
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
tf.word_wrap = True
for i, bullet in enumerate(bullets):
p = tf.paragraphs[0] if i == 0 else tf.add_paragraph()
p.text = f• {bullet}
p.font.size = Pt(18)
p.font.color.rgb = self.colors[text]
p.space_after = Pt(12)
return slide
def addtwocolumnslide(self, title, leftcontent, right_content):
添加双栏内容页
slide = self.prs.slides.addslide(self.prs.slidelayouts[6])
self.setslide_bg(slide, self.colors[bg])
self.addtitle_bar(slide, title)
# 左栏
leftbox = slide.shapes.addtextbox(Inches(0.5), Inches(1.5), Inches(4.5), Inches(5))
lefttf = leftbox.text_frame
lefttf.wordwrap = True
for i, item in enumerate(left_content):
p = lefttf.paragraphs[0] if i == 0 else lefttf.add_paragraph()
p.text = f• {item}
p.font.size = Pt(16)
p.font.color.rgb = self.colors[text]
p.space_after = Pt(10)
# 右栏
rightbox = slide.shapes.addtextbox(Inches(5.2), Inches(1.5), Inches(4.5), Inches(5))
righttf = rightbox.text_frame
righttf.wordwrap = True
for i, item in enumerate(right_content):
p = righttf.paragraphs[0] if i == 0 else righttf.add_paragraph()
p.text = f• {item}
p.font.size = Pt(16)
p.font.color.rgb = self.colors[text]
p.space_after = Pt(10)
return slide
def addtableslide(self, title, headers, rows):
添加表格页
slide = self.prs.slides.addslide(self.prs.slidelayouts[6])
self.setslide_bg(slide, self.colors[bg])
self.addtitle_bar(slide, title)
# 创建表格
rows_count = len(rows) + 1
cols_count = len(headers)
left, top = Inches(0.5), Inches(1.8)
width, height = Inches(9), Inches(4)
tableshape = slide.shapes.addtable(rowscount, colscount, left, top, width, height)
table = table_shape.table
# 设置表头
for i, header in enumerate(headers):
cell = table.cell(0, i)
cell.text = header
cell.fill.solid()
cell.fill.fore_color.rgb = self.colors[primary]
for paragraph in cell.text_frame.paragraphs:
paragraph.font.size = Pt(14)
paragraph.font.bold
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 pptx-generator-1776016304 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 pptx-generator-1776016304 技能
skillhub install pptx-generator-1776016304
文件大小: 4.76 KB | 发布时间: 2026-4-13 11:35