Name | pptx-renderer JSON |
Version |
0.5.2
JSON |
| download |
home_page | None |
Summary | Render ppt like a jupyter notebook |
upload_time | 2024-12-09 15:26:19 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
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. |
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.
[Documentation](https://pptx-renderer.readthedocs.io/en)
## 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)}}}`
## Repeating slides
If you define `loop_groups` keyword argument as part of render method, you can
repeat groups of slides. The value of `loop_groups` should be a list of dictionaries.
Each dictionary should have the following keys
- `start`: The slide number where the loop should start
- `end`: The slide number where the loop should end
- `iterable`: The iterable which should be looped over.
- `variable`: The name of the variable which will be available inside the loop.
For example, if you want to insert all images from a folder into a ppt, one image
per slide, you can do the following.
Create a template ppt with a single slide which contains a rectangle shape where
the image should be inserted. Then insert a placeholder text in the format
`{{{path_to_image:image()}}}` inside the shape. Then you can use the following
```python
from pathlib import Path
from pptx_renderer import PPTXRenderer
p = PPTXRenderer("template.pptx")
images = Path("path/to/images").glob("*.png")
loop_groups = [
{
"start": 0,
"end": 0,
"iterable": images,
"variable": "path_to_image"
}
]
p.render(
"output.pptx",
loop_groups = loop_groups
)
```
This will create a new ppt with each image from the folder inserted into a new slide.
Raw data
{
"_id": null,
"home_page": null,
"name": "pptx-renderer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "powerpoint, ppt, pptx, presentation, slides",
"author": null,
"author_email": "Najeem Muhammed <najeem@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/cc/94/8b7ebbc47a214a59769d1a0495e3ad96b280f80ebc4cf65e36f83397721d/pptx_renderer-0.5.2.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[Documentation](https://pptx-renderer.readthedocs.io/en)\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\n## Repeating slides\n\nIf you define `loop_groups` keyword argument as part of render method, you can\nrepeat groups of slides. The value of `loop_groups` should be a list of dictionaries.\nEach dictionary should have the following keys\n- `start`: The slide number where the loop should start\n- `end`: The slide number where the loop should end\n- `iterable`: The iterable which should be looped over.\n- `variable`: The name of the variable which will be available inside the loop.\n\nFor example, if you want to insert all images from a folder into a ppt, one image\nper slide, you can do the following.\n\nCreate a template ppt with a single slide which contains a rectangle shape where\nthe image should be inserted. Then insert a placeholder text in the format\n`{{{path_to_image:image()}}}` inside the shape. Then you can use the following\n\n```python\nfrom pathlib import Path\nfrom pptx_renderer import PPTXRenderer\np = PPTXRenderer(\"template.pptx\")\n\nimages = Path(\"path/to/images\").glob(\"*.png\")\nloop_groups = [\n {\n \"start\": 0,\n \"end\": 0,\n \"iterable\": images,\n \"variable\": \"path_to_image\"\n }\n]\n\np.render(\n \"output.pptx\",\n loop_groups = loop_groups\n)\n```\n\nThis will create a new ppt with each image from the folder inserted into a new slide.\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.5.2",
"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": "9da2c9c9d84a299eac80a650f585ccbf3cad5ff4d987d4e4b4e09848283069cb",
"md5": "71ad4bf55a1623da519f9f4eb6c4f00d",
"sha256": "cd8cdbc6b6f4dfeea891d0d46ea5530749ad557d1f12821ba58babdedba22ceb"
},
"downloads": -1,
"filename": "pptx_renderer-0.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "71ad4bf55a1623da519f9f4eb6c4f00d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 13084,
"upload_time": "2024-12-09T15:26:18",
"upload_time_iso_8601": "2024-12-09T15:26:18.369098Z",
"url": "https://files.pythonhosted.org/packages/9d/a2/c9c9d84a299eac80a650f585ccbf3cad5ff4d987d4e4b4e09848283069cb/pptx_renderer-0.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cc948b7ebbc47a214a59769d1a0495e3ad96b280f80ebc4cf65e36f83397721d",
"md5": "48ddc42046aa26d67ead868398fb3f93",
"sha256": "313cab87ff62c45c264efcff562b5fc90f6a0066d669b0af1d2836df7dec359a"
},
"downloads": -1,
"filename": "pptx_renderer-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "48ddc42046aa26d67ead868398fb3f93",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 14466,
"upload_time": "2024-12-09T15:26:19",
"upload_time_iso_8601": "2024-12-09T15:26:19.910834Z",
"url": "https://files.pythonhosted.org/packages/cc/94/8b7ebbc47a214a59769d1a0495e3ad96b280f80ebc4cf65e36f83397721d/pptx_renderer-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-09 15:26:19",
"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"
}