Skip to main content

PPTT

PyPI - Python Version PyPI PyPI download month codecov HitCount

PowerPoint Template for python

Installation

$ pip install PPTT
✨🍰✨

How to use it?

make master pptx

link how to make master pptx

master.pptx preview

master_preview

make page!

create slide.json like this

{
  "pages": [
    {
      "slide_pos": 1,
      "contents": {
        "title": {
          "text": "PPTT"
        },
        "subtitle": {
          "text": "you don't need to config design"
        }
      }
    },
    {
      "slide_pos": 2,
      "contents": {
        "title": {
          "text": "Replace Table Data"
        },
        "table": {
          "table": {
            "data_type": "key_value",
            "keys": [
              "Name",
              "Age",
              {
                "name": "Hobby",
                "data_key": "hobby"
              },
              {
                "name": {
                  "value": "Language",
                  "font": {
                    "bold": true,
                    "italic": true,
                    "underline": true,
                    "color": "#00F900"
                  }
                },
                "data_key": "language"
              }
            ],
            "data": [
              {"Name": "sinsky", "Age": 28, "hobby": "programming", "language": "korean"},
              {"Name": "summer", "Age": 4, "hobby": "reading", "language": "korean"},
              {"Name": "emmit", "Age": 30, "hobby": "lego", "language": "english"},
              {"Name": "agent", "Age": 20, "hobby": "hiding", "language": "english"},
              {
                "Name": "python",
                "Age": 38,
                "hobby": "making",
                "language": {
                  "value": "python",
                  "font": {
                    "bold": true,
                    "color": "#FFC107"
                  }
                }
              }
            ]
          }
        }
      }
    },
    {
      "slide_pos": 3,
      "contents": {
        "title": {
          "text": "Replace Chart Data"
        },
        "chart": {
          "chart": {
            "data_type": "category_data",
            "title": "this is new chart",
            "categories": ["list", "dict", "str"],
            "series": {
              "series 1": [5, 13, 8]
            }
          }
        }
      }
    },
    {
      "slide_pos": 4,
      "contents": {
        "body": {
          "text": "support multi-line\ntext\nlike this"
        },
        "table": {
          "table": {
            "data_type": "raw",
            "data": [
              [null, "1Q", {"value": "2Q", "font": {"bold": true}}],
              ["Apple", 10, {"value": 20, "font": {"italic": true}}],
              ["Google", 8, {"value": 8, "font": {"underline": true}}],
              ["AWS", 20, {"value": 15, "font": {"color": "00F900"}}]
            ]
          }
        },
        "chart": {
          "chart": {
            "data_type": "category_data",
            "categories": ["Apple", "Google", "AWS"],
            "series": {
              "1Q": [10, 8, 20],
              "2Q": [20, 6, 15]
            }
          }
        }
      }
    }
  ]
}

make ppt!

pptt make_ppt master.pptx clone.pptx -i slide.json
clone.pptx preview

master_preview

Python API

make stub file

pptt make_stub master.pptx -o slide_stubs.py

make ppt as code

import os

from PPTT.ppt import make_ppt
from PPTT.type import TextData, KeyValueData, TableData, KVKey, FontData, ChartCategoryData, \
    CategoryData, TextStyle, RawData
from slide_stubs import \
    Slide1 as CoverSlide, Slide1Content as CoverSlideContent, \
    Slide2 as TableSlide, Slide2Content as TableSlideContent, \
    Slide3 as ChartSlide, Slide3Content as ChartSlideContent, \
    Slide4 as ComboSlide, Slide4Content as ComboSlideContent

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

if __name__ == '__main__':
    slieds = []
    # slide 1
    cover_content = CoverSlideContent(
        title=TextData(text='PPTT'),
        subtitle=TextData(text="you don't need to config design")
    )

    slieds.append(CoverSlide(contents=cover_content))

    python_font = FontData(bold=True, color="#FFC107")
    language_font = FontData(bold=True, italic=True, underline=True, color="#00F900")
    # slide 2
    table_content = TableSlideContent(
        title=TextData(text="Replace Table Data"),
        table=TableData(table=KeyValueData(
            keys=[
                'Name',
                "Age",
                KVKey(name='Hobby', data_key="hobby"),
                KVKey(name=TextStyle(value="Language", font=language_font), data_key="language")
            ],
            data=[
                {"Name": "sinsky", "Age": 28, "hobby": "programming", "language": "korean"},
                {"Name": "summer", "Age": 4, "hobby": "reading", "language": "korean"},
                {"Name": "emmit", "Age": 30, "hobby": "lego", "language": "english"},
                {"Name": "agent", "Age": 20, "hobby": "hiding", "language": "english"},
                {"Name": "python", "Age": 38, "hobby": "making",
                 "language": TextStyle(value="python", font=python_font)
                 }
            ]
        )
        )
    )
    slieds.append(TableSlide(contents=table_content))

    # slide3
    chart_data = CategoryData(
        title="this is new chart",
        categories=['list', 'dict', 'str'],
        series={
            "series 1": [5, 13, 8]
        }
    )

    chart_content = ChartSlideContent(
        title=TextData(text="Replace Chart Data"),
        chart=ChartCategoryData(chart_data)
    )
    slieds.append(ChartSlide(contents=chart_content))

    # slide4
    table_raw_data = RawData(data=[
        [None, "1Q", TextStyle("2Q", font=FontData(bold=True))],
        ["Apple", 10, TextStyle(20, font=FontData(italic=True))],
        ["Google", 8, TextStyle(8, font=FontData(underline=True))],
        ["AWS", 20, TextStyle(15, font=FontData(color="#00F900"))]
    ])

    chart_category_data = CategoryData(
        categories=["Apple", "Google", "AWS"],
        series={
            "1Q": [10, 8, 20],
            "2Q": [20, 6, 15]
        }
    )

    combo_content = ComboSlideContent()
    combo_content.body = TextData("support multi-line\ntext\nlike this")
    combo_content.table = TableData(table_raw_data)
    combo_content.chart = ChartCategoryData(chart_category_data)

    slieds.append(ComboSlide(contents=combo_content))

    master_file = os.path.join(BASE_DIR, 'master.pptx')
    export_file = os.path.join(BASE_DIR, 'clone.pptx')

    make_ppt(master_file, export_file, pages=slieds)

test

. ./tests.sh

Change Logs

  • 0.0.1

    • add cli version
    • cli usecase example
  • 0.0.2

  • 0.0.3

    • remove feature : I will refactoring ASAP
      • python api feature
      • template mode
    • add replace mode
    • update simple usecase example
    • support table data replace
      • support data type : raw, key_value
    • support chart data replace
      • support data type : category_data
  • 0.0.4

    • New Feature
      • support all chart data tye : xy_data, bubble_data
    • Docs
  • 0.0.5

    • Bug Fix
      • fix table replace data dose not reset issue
  • 0.0.6

    • New Feature
      • change text font style #10
  • 0.0.7

    • New Feature
      • make slide stub for python api
  • 0.0.8

    • New Feature
      • now you can give alias to stub class example
  • 0.0.9

    • New Feature
      • support delete slide

Release files for PPTT 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PPTT 0.0.9
File Size Uploaded
PPTT-0.0.9.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PPTT 0.0.9
File Interpreter ABI Platform
PPTT-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size:39.7 kB

Release files / PPTT-0.0.9.tar.gz

Download URL PPTT-0.0.9.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5101ce5587b37c1e1d9eaa4604d8e48a8ae51a229562a5d48cc5edef6a8a689d
BLAKE2b-256 checksum
How to use checksums
76a965ed69ebe1ff4dc2ee01865f3c43f6282dd9395cf06ea18128d729802c39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

Release files / PPTT-0.0.9-py3-none-any.whl

Download URL PPTT-0.0.9-py3-none-any.whl
Size 22.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba9242610be763e8f4f7ce59717a7354a48776959ce4c093187705818fa5a623
BLAKE2b-256 checksum
How to use checksums
c2a9db77473e594d6016e943f24b67d066e84b90d074f5d8b1480f70cc5ae747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page