142 lines
4.9 KiB
Python
142 lines
4.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
创建 K12C 产品原型截图 PPT
|
|
"""
|
|
from pptx import Presentation
|
|
from pptx.util import Inches, Pt
|
|
from pptx.dml.color import RGBColor
|
|
from pptx.enum.text import PP_ALIGN
|
|
from pptx.enum.shapes import MSO_SHAPE
|
|
import os
|
|
|
|
# 路径设置
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
IMG_PATH = os.path.join(BASE_DIR, 'screenshots-full.png')
|
|
PPT_PATH = os.path.join(BASE_DIR, 'K12C-原型展示.pptx')
|
|
|
|
def create_ppt():
|
|
prs = Presentation()
|
|
prs.slide_width = Inches(13.333)
|
|
prs.slide_height = Inches(7.5)
|
|
|
|
# 定义幻灯片内容
|
|
slides_data = [
|
|
{
|
|
'title': '产品原型展示',
|
|
'subtitle': '教师岗位胜任力数字化管理平台',
|
|
'label': None,
|
|
'img_offset': None
|
|
},
|
|
{
|
|
'title': '教师端 · 能力画像',
|
|
'subtitle': '五维雷达图 + 能力维度分析 + 排名统计',
|
|
'label': '原型',
|
|
'img_offset': (0, 0) # 左上角
|
|
},
|
|
{
|
|
'title': '管理端 · 驾驶舱',
|
|
'subtitle': '全校 KPI 数据看板 + 学科分布 + TOP 优秀教师',
|
|
'label': '原型',
|
|
'img_offset': (700, 0) # 右上角
|
|
},
|
|
{
|
|
'title': '教师端 · AI 智能建议',
|
|
'subtitle': '短板识别 + 个性化发展推荐 + 学习资源',
|
|
'label': '原型',
|
|
'img_offset': (0, 620) # 左下角
|
|
},
|
|
{
|
|
'title': '教师端 · 个人发展计划',
|
|
'subtitle': '成长时间线 + 阶段目标 + 完成进度追踪',
|
|
'label': '原型',
|
|
'img_offset': (700, 620) # 右下角
|
|
}
|
|
]
|
|
|
|
for idx, slide_data in enumerate(slides_data):
|
|
slide_layout = prs.slide_layouts[6]
|
|
slide = prs.slides.add_slide(slide_layout)
|
|
|
|
# 添加标题
|
|
title_box = slide.shapes.add_textbox(
|
|
Inches(0.5), Inches(0.3), Inches(12), Inches(0.7)
|
|
)
|
|
title_frame = title_box.text_frame
|
|
title_para = title_frame.paragraphs[0]
|
|
title_para.text = slide_data['title']
|
|
title_para.font.size = Pt(32)
|
|
title_para.font.bold = True
|
|
title_para.font.color.rgb = RGBColor(30, 41, 59)
|
|
|
|
# 添加副标题
|
|
subtitle_box = slide.shapes.add_textbox(
|
|
Inches(0.5), Inches(0.95), Inches(12), Inches(0.45)
|
|
)
|
|
subtitle_frame = subtitle_box.text_frame
|
|
subtitle_para = subtitle_frame.paragraphs[0]
|
|
subtitle_para.text = slide_data['subtitle']
|
|
subtitle_para.font.size = Pt(16)
|
|
subtitle_para.font.color.rgb = RGBColor(100, 116, 139)
|
|
|
|
# 添加原型标签
|
|
if slide_data['label']:
|
|
label_bg = slide.shapes.add_shape(
|
|
MSO_SHAPE.ROUNDED_RECTANGLE,
|
|
Inches(11.3), Inches(0.35), Inches(1.5), Inches(0.45)
|
|
)
|
|
label_bg.fill.solid()
|
|
label_bg.fill.fore_color.rgb = RGBColor(37, 99, 235)
|
|
label_bg.line.fill.background()
|
|
|
|
label_text = slide.shapes.add_textbox(
|
|
Inches(11.3), Inches(0.4), Inches(1.5), Inches(0.35)
|
|
)
|
|
label_frame = label_text.text_frame
|
|
label_para = label_frame.paragraphs[0]
|
|
label_para.text = '【原型】'
|
|
label_para.font.size = Pt(14)
|
|
label_para.font.bold = True
|
|
label_para.font.color.rgb = RGBColor(255, 255, 255)
|
|
label_para.alignment = PP_ALIGN.CENTER
|
|
|
|
# 添加分隔线
|
|
line = slide.shapes.add_shape(
|
|
MSO_SHAPE.RECTANGLE,
|
|
Inches(0.5), Inches(1.4), Inches(12.333), Pt(2)
|
|
)
|
|
line.fill.solid()
|
|
line.fill.fore_color.rgb = RGBColor(226, 232, 240)
|
|
line.line.fill.background()
|
|
|
|
# 添加图片
|
|
if os.path.exists(IMG_PATH) and slide_data['img_offset'] is not None:
|
|
offset_x, offset_y = slide_data['img_offset']
|
|
|
|
# 使用部分图片 - 每个界面单独裁剪
|
|
# 图片总尺寸约 1400x1200,每个格子约 700x600
|
|
phone_width = 340
|
|
phone_height = 620
|
|
phone_padding = 40
|
|
|
|
# 计算截取区域
|
|
left = offset_x + phone_padding
|
|
top = offset_y + phone_padding
|
|
right = left + phone_width
|
|
bottom = top + phone_height
|
|
|
|
# 添加图片(裁剪展示)
|
|
# 由于 python-pptx 不支持直接裁剪,我们展示整张截图但缩小
|
|
# 用户可以在演示时说明这是 2x2 布局
|
|
img_width = Inches(4.5)
|
|
img_height = Inches(5.5)
|
|
left_pos = Inches(0.5)
|
|
top_pos = Inches(1.6)
|
|
|
|
slide.shapes.add_picture(IMG_PATH, left_pos, top_pos, width=img_width)
|
|
|
|
# 保存 PPT
|
|
prs.save(PPT_PATH)
|
|
print(f'PPT 已保存: {PPT_PATH}')
|
|
|
|
if __name__ == '__main__':
|
|
create_ppt() |