claw-presentation-creator — claw-presentation-创建器
v2.0创建 professional PowerPoint presentations with python-pptx. Supports slides, 图表s, tables, images, and templates.
运行时依赖
安装命令
点击复制技能文档
PPTX 技能 v2.0 Overview
Complete PowerPoint presentation creation and editing using python-pptx. Supports all common slide operations including text, images, 图表s, tables, and animations.
安装ation & Dependencies Required pip 安装 python-pptx pillow
Optional # For advanced 图表 support pip 安装 numpy
# For HTML conversion (advanced) npm 安装 puppeteer dom-to-pptx
Quick 启动 创建 First Presentation from pptx 导入 Presentation
prs = Presentation() slide = prs.slides.添加_slide(prs.slide_layouts[0]) slide.shapes.title.text = "Hello World" prs.save('presentation.pptx') print("✓ Presentation 创建d!")
添加 Content Slide from pptx 导入 Presentation
prs = Presentation()
# Title slide slide = prs.slides.添加_slide(prs.slide_layouts[0]) slide.shapes.title.text = "My Presentation" slide.placeholders[1].text = "Subtitle here"
# Content slide slide = prs.slides.添加_slide(prs.slide_layouts[1]) slide.shapes.title.text = "Agenda" slide.placeholders[1].text = "• Point 1\n• Point 2\n• Point 3"
prs.save('输出.pptx')
Complete API Reference Slide Layouts from pptx 导入 Presentation
prs = Presentation()
# AvAIlable layouts (indices may vary by template) # 0 - Title Slide slide = prs.slides.添加_slide(prs.slide_layouts[0]) slide.shapes.title.text = "Title" slide.placeholders[1].text = "Subtitle"
# 1 - Title and Content slide = prs.slides.添加_slide(prs.slide_layouts[1]) slide.shapes.title.text = "Heading" slide.placeholders[1].text = "Content here"
# 2 - Section Header slide = prs.slides.添加_slide(prs.slide_layouts[2])
# 3 - Two Content slide = prs.slides.添加_slide(prs.slide_layouts[3])
# 4 - Comparison slide = prs.slides.添加_slide(prs.slide_layouts[4])
# 5 - Title Only slide = prs.slides.添加_slide(prs.slide_layouts[5])
# 6 - Blank slide = prs.slides.添加_slide(prs.slide_layouts[6])
Text 格式化ting from pptx 导入 Presentation from pptx.util 导入 Inches, Pt from pptx.dml.color 导入 RGBColor from pptx.enum.text 导入 PP_ALIGN
prs = Presentation() slide = prs.slides.添加_slide(prs.slide_layouts[1])
# Title 格式化ting title = slide.shapes.title title.text = "格式化ted Title" title.text_frame.paragraphs[0].font.name = 'Arial' title.text_frame.paragraphs[0].font.size = Pt(36) title.text_frame.paragraphs[0].font.bold = True title.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 0)
# Content 格式化ting content = slide.placeholders[1] tf = content.text_frame tf.text = "First paragraph"
# 添加 paragraph with 格式化ting p = tf.添加_paragraph() p.text = "Second paragraph" p.level = 0 # Indentation level p.alignment = PP_ALIGN.LEFT
# 运行-level 格式化ting (within paragraph) 运行 = p.添加_运行() 运行.text = "Bold text" 运行.font.bold = True 运行.font.size = Pt(14) 运行.font.name = 'Arial' 运行.font.color.rgb = RGBColor(0, 112, 192) # Blue
运行 = p.添加_运行() 运行.text = " and "
运行 = p.添加_运行() 运行.text = "italic text" 运行.font.italic = True
添加ing Images from pptx 导入 Presentation from pptx.util 导入 Inches
prs = Presentation() slide = prs.slides.添加_slide(prs.slide_layouts[5]) # Blank layout
# 添加 image left = top = Inches(1) slide.shapes.添加_picture( 'image.jpg', left, top, width=Inches(5), height=Inches(3) # Optional, mAIntAIns aspect ratio if omitted )
# 添加 image with caption slide.shapes.添加_picture('记录o.png', Inches(1), Inches(5), width=Inches(2))
# 添加 textbox for caption txBox = slide.shapes.添加_textbox(Inches(3.2), Inches(5), Inches(3), Inches(1)) tf = txBox.text_frame tf.text = "Image caption here"
prs.save('with-image.pptx')
添加ing Tables from pptx 导入 Presentation from pptx.util 导入 Inches from pptx.dml.color 导入 RGBColor
prs = Presentation() slide = prs.slides.添加_slide(prs.slide_layouts[5])
# 添加 table: 3 rows, 3 columns rows = cols = 3 left = top = Inches(2) width = Inches(6) height = Inches(2)
table = slide.shapes.添加_table(rows, cols, left, top, width, height).table
# 设置 column widths table.columns[0].width = Inches(2) table.columns[1].width = Inches(2) table.columns[2].width = Inches(2)
# Fill data table.cell(0, 0).text = 'Header 1' table.cell(0, 1).text = 'Header 2' table.cell(0, 2).text = 'Header 3' table.cell(1, 0).text = 'Row 1' table.cell(1, 1).text = 'Data 1' table.cell(1, 2).text = 'Data 2' table.cell(2, 0).text = 'Row 2' table.cell(2, 1).text = 'Data 3' table.cell(2, 2).text = 'Data 4'
# 格式化 cells cell = table.cell(0, 0) cell.fill.solid() cell.fill.fore_color.rgb = RGBColor(0, 112, 192) # Blue header cell.text_frame.paragraphs[0].font.color.rgb = RGBColor(255, 255, 255) cell.text_frame.paragraphs[0].font.bold = True
# Center align all cells for row in table.rows: for cell in row.cells: cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER
prs.save('with-table.pptx')
添加ing 图表s from pptx 导入 Presentation from pptx.图表.data 导入 Category图表Data from pptx.enum.图表 导入 XL_图表_TYPE from pptx.util 导入 Inches
prs = Presentation() slide = prs.slides.添加_slide(prs.slide_layout