The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a Python slide deck generator

Here’s a basic Python slide deck generator that creates a presentation using the python-pptx library. It allows you to generate PowerPoint slides from a structured list of slide titles and bullet points.


🔧 Requirements

Install the required library:

bash
pip install python-pptx

🧠 Code: Python Slide Deck Generator

python
from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.shapes import MSO_SHAPE from pptx.dml.color import RGBColor def create_slide(prs, title, bullet_points): slide_layout = prs.slide_layouts[1] # Title and Content layout slide = prs.slides.add_slide(slide_layout) title_placeholder = slide.shapes.title content_placeholder = slide.placeholders[1] title_placeholder.text = title content_frame = content_placeholder.text_frame content_frame.clear() for point in bullet_points: p = content_frame.add_paragraph() p.text = point p.level = 0 p.font.size = Pt(18) p.font.name = 'Arial' p.font.color.rgb = RGBColor(0, 0, 0) def generate_presentation(title, author, slides_data, output_file="presentation.pptx"): prs = Presentation() # Title Slide title_slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(title_slide_layout) slide.shapes.title.text = title slide.placeholders[1].text = f"By {author}" # Content Slides for slide_data in slides_data: create_slide(prs, slide_data['title'], slide_data['bullets']) prs.save(output_file) print(f"Presentation saved as '{output_file}'") # Example usage if __name__ == "__main__": presentation_title = "Introduction to Python" author_name = "John Doe" slides = [ { "title": "What is Python?", "bullets": [ "High-level programming language", "Interpreted and dynamically typed", "Great for scripting and automation" ] }, { "title": "Why Learn Python?", "bullets": [ "Readable and beginner-friendly syntax", "Huge community support", "Widely used in web, data science, AI, and more" ] }, { "title": "Popular Python Libraries", "bullets": [ "NumPy, pandas, matplotlib", "Django, Flask", "TensorFlow, PyTorch" ] } ] generate_presentation(presentation_title, author_name, slides)

📂 Output

A .pptx file named presentation.pptx will be created in the same directory, containing:

  • A title slide

  • Multiple content slides with bullet points


✅ Features

  • Custom slide titles and content

  • Basic text formatting

  • Easily extensible with charts, images, or custom styling

Let me know if you’d like to add advanced features like theme support, images, or content from Markdown or CSV.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About