ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

python库 pptx_designer 项目 api 文档

python库 pptx_designer 项目 api 文档 API 参考适用版本1.0.0-beta.2。此页仅列出稳定且已存在的公共入口具体 SVG 支持范围见 SVG 编译器指南。Top-Level Functionsgenerate_pptGenerate a complete PowerPoint presentation from a text description.frompptx_designerimportgenerate_ppt resultgenerate_ppt(query:str,# Natural language description*,style:str|NoneNone,# Design style (e.g., dark cyberpunk)palette:str|NoneNone,# Exact color palette namefonts:str|NoneNone,# Exact font pair namedecoration:str|NoneNone,# Decoration stylelayout:str|NoneNone,# Layout variantmood:str|NoneNone,# Mood categoryslides:int6,# Number of slidesoutput:str|NoneNone,# Output file pathfetch_images:boolFalse,# Enable AI image generationimage_mode:strauto,# Image modellm_provider:str|NoneNone,llm_api_key:str|NoneNone,)-dict:Returns dict with keys: output_path, slide_count, shapes_count.fetch_imageGenerate or search for an image.frompptx_designerimportfetch_image resultfetch_image(keywords:str,# Search/generation prompt*,mode:strauto,# placeholder|search|generate|enhance|autollm_provider:str|NoneNone,llm_api_key:str|NoneNone,width:int1920,height:int1080,)-dict:Returns dict with keys: path, mode, provider, keywords.extract_design_dnaExtract design analysis from an existing .pptx file.frompptx_designerimportextract_design_dna dnaextract_design_dna(pptx_path:str)-dictToolspptx_designer.tools.shapesShape creation functions.FunctionDescriptionrect(slide, left, top, width, height, *, fill, ...)Rectanglerounded_rect(slide, left, top, width, height, *, fill, radius, ...)Rounded rectangleoval(slide, left, top, width, height, *, fill, ...)Ovalhexagon(slide, cx, cy, size, *, fill, ...)Hexagondiamond(slide, cx, cy, size, *, fill, ...)Diamondstar(slide, cx, cy, radius, *, points, fill, ...)Startriangle(slide, left, top, width, height, *, fill, ...)Trianglearrow(slide, left, top, width, height, *, fill, ...)Arrowchevron(slide, left, top, width, height, *, fill, ...)Chevroncloud(slide, left, top, width, height, *, fill, ...)Cloudheart(slide, cx, cy, size, *, fill, ...)Heartpptx_designer.tools.textText functions.FunctionDescriptiontext(slide, left, top, width, height, txt, *, font_size, color, bold, align)Single-line textmultiline(slide, left, top, width, height, lines, *, font_size, color)Multi-line textgradient_text(slide, left, top, width, height, txt, *, preset, font_size)Gradient textdramatic_text(slide, left, top, width, height, big, small, ...)Size-contrast textvertical_text(slide, left, top, width, height, txt, ...)Vertical CJK textpptx_designer.tools.imagesImage functions.FunctionDescriptioncover_image(slide, left, top, width, height, image_path)Cover-fit imagecircle_image(slide, cx, cy, radius, image_path, ...)Circle-clipped imageai_image(slide, left, top, width, height, keywords, ...)AI generate placeduotone_image(slide, left, top, width, height, image_path, ...)Duotone effectpptx_designer.tools.chartsChart functions.FunctionDescriptionbar_chart(slide, left, top, data, ...)Horizontal bar chartdonut_chart(slide, cx, cy, radius, sectors, ...)Donut/pie chartnative_chart(slide, left, top, width, height, chart_type, ...)Native PPT chartDiagramsfrompptx_designer.diagramsimportflowchart,timeline,swot,matrix,cycle,funnel flowchart.render(slide,steps,region,style)timeline.render(slide,events,region,style)swot.render(slide,data,region,style)Effectsfrompptx_designer.effectsimporttext_fx,shape_fx,animation# Text effectstext_fx.apply_gradient(run,stops)text_fx.apply_shadow(shape,blur8)text_fx.apply_glow(shape,color#FF0000)# Shape effectsshape_fx.apply_gradient(shape,#FF0000,#0000FF)shape_fx.apply_3d(shape,depth10)shape_fx.apply_pattern(shape,cross,fg#000,bg#FFF)# Animationanimation.add_transition(slide,morph)animation.add_entrance(slide,shape_id,fade_in)Compilerfrompptx_designer.compilerimportSVGCompileError,SVGCompiler compilerSVGCompiler()resultcompiler.compile(svg_text,slide,rect(1.0,1.0,8.0,4.0),# x, y, width, height; inches)print(result.shape_count)print(result.warnings)print(result.features)For the convenient Build-mode wrapper:frompptx_designer.tools.svgimportsvg_chart resultsvg_chart(slide,svg_text,x1.0,y1.0,w8.0,h4.0)SVGResultincludesshape_count,shapes,native_shapes,warnings,errors,features,feature_levels,source_to_output,metrics, andcompile_ms. Invalid SVG or a configured safety limit raisesSVGCompileError; unsupported individual elements may instead be skipped with a warning. Production callers should handle both paths.
返回列表