Skip to main content

RevealPy is a Python library for creating beautiful and interactive presentations programmatically. It provides a simple yet powerful API to create presentations with various content types and layouts

Project description

RevealPy Documentation

RevealPy is a Python library for creating beautiful and interactive presentations programmatically. It provides a simple yet powerful API to create presentations with various content types and layouts.

Installation

pip install revealpy

Quick Start

from revealpy import Presentation
from revealpy import LayoutType

# Create a new presentation
presentation = Presentation(theme="black", transition="fade")

# Create a title slide
slide = presentation.create_slide("My First Presentation")
slide.add_text("Created with RevealPy")

# Export the presentation
presentation.export("my_presentation.html")

Core Components

Presentation Class

The main class for creating presentations.

presentation = Presentation(
    theme="black",     # Presentation theme
    transition="fade"  # Slide transition effect
)

Methods:

  • create_slide(title: str) -> SlideBuilder: Creates a new slide
  • render() -> str: Renders the presentation as HTML
  • export(filename: str): Exports the presentation to HTML
  • export_pptx(filename: str): Exports the presentation to PowerPoint format

SlideBuilder Class

Used to build individual slides with various content types and layouts.

Basic Methods

slide = presentation.create_slide("Slide Title")

# Add different types of content
slide.add_text("Simple text content")
slide.add_bullet_points(["Point 1", "Point 2", "Point 3"])
slide.add_numbered_list(["First item", "Second item"])
slide.add_code("print('Hello World')", language="python")

Layout Configuration

slide.set_layout(LayoutType.TWO_COLUMNS)
slide.configure_layout(
    title_size="h2",
    content_align="left",
    background="#f0f0f0",
    extra_classes=["custom-class"]
)

Available Layout Types

  • TITLE: Only title
  • TITLE_CONTENT: Title and content
  • TWO_COLUMNS: Title and two columns
  • TITLE_TWO_CONTENT: Title and content in two rows
  • COMPARISON: Title and two columns with headers
  • SECTION: Big title for section breaks
  • BLANK: Blank slide for custom content
  • IMAGE_WITH_CAPTION: Centered image with caption
  • QUOTE: Quote with optional attribution

Content Types

Text Content

slide.add_text("Regular paragraph text")

Lists

slide.add_bullet_points([
    "First bullet point",
    "Second bullet point",
    "Third bullet point"
])

slide.add_numbered_list([
    "First numbered item",
    "Second numbered item"
])

Code Blocks

slide.add_code(
    code="def hello_world():\n    print('Hello, World!')",
    language="python"
)

Images

slide.add_image(
    url="path/to/image.jpg",
    caption="Optional image caption"
)

Equations

slide.add_equation(
    equation="E = mc^2",
    description={
        "E": "Energy",
        "m": "Mass",
        "c": "Speed of light"
    }
)

Tables

slide.add_table(
    headers=["Name", "Age", "City"],
    rows=[
        ["John", "25", "New York"],
        ["Alice", "30", "London"]
    ]
)

Diagrams

slide.add_diagram("""
    graph TD
    A[Start] --> B[Process]
    B --> C[End]
""")

Media

slide.add_media(
    url="path/to/video.mp4",
    media_type="video"  # or "audio"
)

Markdown

slide.add_markdown("""
# Markdown Title
- Point 1
- Point 2

```python
print('Code block')

""")


## Working with Two-Column Layouts

When using `TWO_COLUMNS` or `COMPARISON` layouts:

```python
slide = presentation.create_slide("Two Columns Example")
slide.set_layout(LayoutType.TWO_COLUMNS)

# Add content to left column
slide.add_to_column(0, Content(ContentType.TEXT, "Left column content"))

# Add content to right column
slide.add_to_column(1, Content(ContentType.TEXT, "Right column content"))

For comparison layouts:

slide = presentation.create_slide("Comparison")
slide.set_layout(LayoutType.COMPARISON)
slide.add_comparison("Before", "After")

Export Options

HTML Export

# Export to HTML
presentation.export("presentation.html")

PowerPoint Export

# Export to PowerPoint
presentation.export_pptx("presentation.pptx")

Best Practices

  1. Consistent Layouts: Use consistent layouts throughout your presentation for better visual coherence.
  2. Content Organization: Break down complex content into multiple slides.
  3. Visual Hierarchy: Use different title sizes and layouts to create clear visual hierarchy.
  4. Media Usage: Optimize images and media files before adding them to the presentation.
  5. Transitions: Use subtle transitions for professional presentations.

Examples

Creating a Complete Presentation

from revealpy import Presentation
from revealpy import LayoutType

# Create presentation
pres = Presentation(theme="black")

# Title slide
title_slide = pres.create_slide("RevealPy Presentation")
title_slide.add_text("Created with Python")

# Content slide
content_slide = pres.create_slide("Key Features")
content_slide.add_bullet_points([
    "Easy to use API",
    "Multiple layout options",
    "Support for various content types",
    "Export to HTML and PowerPoint"
])

# Two-column slide
compare_slide = pres.create_slide("Comparison")
compare_slide.set_layout(LayoutType.COMPARISON)
compare_slide.add_comparison("Traditional", "RevealPy")
compare_slide.add_to_column(0, Content(ContentType.TEXT, "Manual creation"))
compare_slide.add_to_column(1, Content(ContentType.TEXT, "Programmatic creation"))

# Export
pres.export("example_presentation.html")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

revealpy-0.1.5.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

revealpy-0.1.5-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file revealpy-0.1.5.tar.gz.

File metadata

  • Download URL: revealpy-0.1.5.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.3 Linux/6.8.0-52-generic

File hashes

Hashes for revealpy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 301399c1469c1e04ee1b5b7a5c576a5f0f96712c590a73e12b936b8291f670ff
MD5 bf6e63f07b16ed3f251b75146d5cc613
BLAKE2b-256 f8a9fbdbb1fd6b0d7d3c383014a03b5ea34ce9bac9faa628b7ad2e2db0826b59

See more details on using hashes here.

File details

Details for the file revealpy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: revealpy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.3 Linux/6.8.0-52-generic

File hashes

Hashes for revealpy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 382e8995a13a0482b9d2b3b37ffc2847d475a8b5eb3c30923ae32fbc3fac9373
MD5 13f8af487a4cf1679d5555848d759c8b
BLAKE2b-256 daba9ada3adda2362d5c3897c5950d7543f6eb10524dbb326f69607bd42b94dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page