pptx-renderer


Namepptx-renderer JSON
Version 0.3.0 PyPI version JSON
download
home_page
SummaryRender ppt like a jupyter notebook
upload_time2023-08-17 07:11:46
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License Copyright (c) 2023, Najeem Muhammed Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords powerpoint ppt pptx presentation slides
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PPTX Renderer

This package let's you run your powerpoint presentations like a jupyter-notebook.
You can insert placeholders in the ppt and also write python code in the ppt's
notes and use either a python function or an equivalent commandline tool to
convert it into an output rendered presentation.

## Installation
```console
pip install pptx-renderer
```

## Usage
Below is a simple example.

```python
from pptx_renderer import PPTXRenderer
p = PPTXRenderer("template.pptx")

someval = "hello"
def mymethod(abc):
    return f"{abc} " * 5

myimage = r"is_it_worth_the_time.png"
mytable = [["a", "b", "c", "d", "e"]] * 10
p.render(
    "output.pptx", 
    {
        "someval": someval, "mymethod": mymethod, "myimage": myimage,
        "mytable": mytable,
    }
)
```

This will convert this

![Before](docs/_src/_static/before.png)

to this.

![After](docs/_src/_static/after.png)


You can define some functions within the ppt itself by writing python code in
the notes section of slides. And the variables and functions in this code
can be used in the main ppt.

For example: write the following in one of the slide's notes.

<pre>
```python
def myfunc(input):
    return input * 42
```
</pre>

Now you can, for example, add the placeholder `{{{myfunc(42)}}}` in your slides.


If the template ppt is a self contained python script ie: if it does not require
variable values and function definition to be passed from outside, you can
generate the output ppt directly from the commandline using the following
command.

```console
pptx-renderer input_template.pptx output_file.pptx
```

## Placeholders
You can have placeholders for text, image or a table. Placeholders can be added
inside text boxes and shapes. All placeholders should be enclosed within a pair
of triple braces (`{{{` and `}}}`).

### Text
Any placeholder which can be evaluated into a string can act as a text placeholder.

For example: `{{{"hello " * 10/2}}}` or `{{{abs(-2)}}}`

### Image
if you have added `:image()` as a suffix to the python statement, the renderer will
try to convert the value of python statement to a file location and insert an
image from that file location.

For example: `{{{"c:\temp\myimage.png":image()}}}`

### Table
Tables are similar to images, but only that instead of a string, the python
statement should evaluate to a list of lists. Then you can add `:table()` as a
suffix and it will be convert to a table inside the ppt.

For example: `{{{[["col1", "col2", "col3"],[1, 2, 3]]:table()}}}` will render to

|col1 | col2 | col3|
|-----|------|-----|
|1    |2     |3    |

## Code in slide notes
You can write regular python code in the slide notes but enclosed between
`` ```python `` and `` ``` ``.

For example: Create a new pptx and write the following in the first slide's notes

<pre lang="python">
```python
import numpy as np
myarr = np.array([[1, 2], [3, 4]])
```
</pre>

And in the slide, create a rectangluar shape and add the text `{{{myarr:table()}}}`
and a text box with the text `The determinant of the array is {{{np.linalg.det(myarr)}}}`

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pptx-renderer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "powerpoint,ppt,pptx,presentation,slides",
    "author": "",
    "author_email": "Najeem Muhammed <najeem@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a1/61/2f18fd59de61df911602cfbb02342a7a5daeccac94b59fec42c755ce8592/pptx_renderer-0.3.0.tar.gz",
    "platform": null,
    "description": "# PPTX Renderer\n\nThis package let's you run your powerpoint presentations like a jupyter-notebook.\nYou can insert placeholders in the ppt and also write python code in the ppt's\nnotes and use either a python function or an equivalent commandline tool to\nconvert it into an output rendered presentation.\n\n## Installation\n```console\npip install pptx-renderer\n```\n\n## Usage\nBelow is a simple example.\n\n```python\nfrom pptx_renderer import PPTXRenderer\np = PPTXRenderer(\"template.pptx\")\n\nsomeval = \"hello\"\ndef mymethod(abc):\n    return f\"{abc} \" * 5\n\nmyimage = r\"is_it_worth_the_time.png\"\nmytable = [[\"a\", \"b\", \"c\", \"d\", \"e\"]] * 10\np.render(\n    \"output.pptx\", \n    {\n        \"someval\": someval, \"mymethod\": mymethod, \"myimage\": myimage,\n        \"mytable\": mytable,\n    }\n)\n```\n\nThis will convert this\n\n![Before](docs/_src/_static/before.png)\n\nto this.\n\n![After](docs/_src/_static/after.png)\n\n\nYou can define some functions within the ppt itself by writing python code in\nthe notes section of slides. And the variables and functions in this code\ncan be used in the main ppt.\n\nFor example: write the following in one of the slide's notes.\n\n<pre>\n```python\ndef myfunc(input):\n    return input * 42\n```\n</pre>\n\nNow you can, for example, add the placeholder `{{{myfunc(42)}}}` in your slides.\n\n\nIf the template ppt is a self contained python script ie: if it does not require\nvariable values and function definition to be passed from outside, you can\ngenerate the output ppt directly from the commandline using the following\ncommand.\n\n```console\npptx-renderer input_template.pptx output_file.pptx\n```\n\n## Placeholders\nYou can have placeholders for text, image or a table. Placeholders can be added\ninside text boxes and shapes. All placeholders should be enclosed within a pair\nof triple braces (`{{{` and `}}}`).\n\n### Text\nAny placeholder which can be evaluated into a string can act as a text placeholder.\n\nFor example: `{{{\"hello \" * 10/2}}}` or `{{{abs(-2)}}}`\n\n### Image\nif you have added `:image()` as a suffix to the python statement, the renderer will\ntry to convert the value of python statement to a file location and insert an\nimage from that file location.\n\nFor example: `{{{\"c:\\temp\\myimage.png\":image()}}}`\n\n### Table\nTables are similar to images, but only that instead of a string, the python\nstatement should evaluate to a list of lists. Then you can add `:table()` as a\nsuffix and it will be convert to a table inside the ppt.\n\nFor example: `{{{[[\"col1\", \"col2\", \"col3\"],[1, 2, 3]]:table()}}}` will render to\n\n|col1 | col2 | col3|\n|-----|------|-----|\n|1    |2     |3    |\n\n## Code in slide notes\nYou can write regular python code in the slide notes but enclosed between\n`` ```python `` and `` ``` ``.\n\nFor example: Create a new pptx and write the following in the first slide's notes\n\n<pre lang=\"python\">\n```python\nimport numpy as np\nmyarr = np.array([[1, 2], [3, 4]])\n```\n</pre>\n\nAnd in the slide, create a rectangluar shape and add the text `{{{myarr:table()}}}`\nand a text box with the text `The determinant of the array is {{{np.linalg.det(myarr)}}}`\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023, Najeem Muhammed  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Render ppt like a jupyter notebook",
    "version": "0.3.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/idling-mind/pptx_renderer/issues",
        "Homepage": "https://github.com/idling-mind/pptx_renderer"
    },
    "split_keywords": [
        "powerpoint",
        "ppt",
        "pptx",
        "presentation",
        "slides"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f387a824e649bf230d37894fe1e4c46e97eb67c6df7cce79e64320a80e51d22a",
                "md5": "f107700cc3894258b5a512e162bed360",
                "sha256": "fc34a6641e8ceb029fb9e8db5d6fefd1d1aac944cfa202204212156bd315dc9b"
            },
            "downloads": -1,
            "filename": "pptx_renderer-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f107700cc3894258b5a512e162bed360",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9458,
            "upload_time": "2023-08-17T07:11:45",
            "upload_time_iso_8601": "2023-08-17T07:11:45.303141Z",
            "url": "https://files.pythonhosted.org/packages/f3/87/a824e649bf230d37894fe1e4c46e97eb67c6df7cce79e64320a80e51d22a/pptx_renderer-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1612f18fd59de61df911602cfbb02342a7a5daeccac94b59fec42c755ce8592",
                "md5": "61795091c9c002e40e4d88cf15a88d09",
                "sha256": "5b7da1635a0d7f574073115971c3e6c1b465c7360c0fe65bdbfcb60e33a5e66b"
            },
            "downloads": -1,
            "filename": "pptx_renderer-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "61795091c9c002e40e4d88cf15a88d09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10310,
            "upload_time": "2023-08-17T07:11:46",
            "upload_time_iso_8601": "2023-08-17T07:11:46.784658Z",
            "url": "https://files.pythonhosted.org/packages/a1/61/2f18fd59de61df911602cfbb02342a7a5daeccac94b59fec42c755ce8592/pptx_renderer-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-17 07:11:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "idling-mind",
    "github_project": "pptx_renderer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pptx-renderer"
}
        
Elapsed time: 0.11080s