pypyt package

Module contents

Renders PowerPoint presentations easily with Python

pypyt.get_shape_type(shape: pptx.shapes.base.BaseShape) → str

Returns a string with the kind of the given shape.

Parameters:shape (BaseShape) – Shape to get the type from.
Returns:String representing the type of the shape
Return type:string

Examples

>>> prs = open_ppt('template.pptx')
>>> shapes = get_shapes_by_name(prs, 'client_name')
>>> get_shape_type(shapes[0])
'paragraph'
pypyt.get_shapes(prs: <function Presentation at 0x000002185E1A9E18>) → tuple

Returns a tuple of tuples with the shape name and shape type.

Parameters:prs (pptx.presentation.Presentation) – Presentation to get the shapes from.
Returns:Tuple with the shapes.
Return type:tuple

Examples

>>> prs = open_ppt('template.pptx')
>>> get_shapes(prs)
(('client_name', 'paragraph'),
 ('presentation_title', 'paragraph'),
 ('slide_text', 'paragraph'),
 ('slide_title', 'paragraph'),
 ('chart', 'chart'),
 ('Title 1', 'paragraph'),
 ('table', 'table'),
 ('Title 1', 'paragraph'))
pypyt.get_shapes_by_name(prs: <function Presentation at 0x000002185E1A9E18>, name: str) → list

Returns a list of shapes with the given name in the given presentation. :param prs: Presentation to be saved. :type prs: pptx.presentation.Presentation :param name: Name of the shape(s) to be returned. :type name: str

Examples

>>> prs = open_ppt('template.pptx')
>>> get_shapes_by_name(prs, 'chart')
[<pptx.shapes.placeholder.PlaceholderGraphicFrame at ...>]
pypyt.is_chart(shape: pptx.shapes.base.BaseShape) → bool

Checks whether the given shape is has a chart

pypyt.is_paragraph(shape: pptx.shapes.base.BaseShape) → bool

Checks whether the given shape is has a paragraph

pypyt.is_table(shape: pptx.shapes.base.BaseShape) → bool

Checks whether the given shape is has a table

pypyt.open_ppt(filename: str) → <function Presentation at 0x000002185E1A9E18>

Opens a pptx file given the filename and returns it.

Parameters:filename (str) – The name of the file to be open.
Returns:Presentation object
Return type:pptx.presentation.Presentation

Examples

>>> open_ppt('template.pptx')
<pptx.presentation.Presentation at ...>
pypyt.pypyt_doc(function=None)

Opens pypyt documentation in the browser.

pypyt.render_and_save_ppt(prs: <function Presentation at 0x000002185E1A9E18>, values: dict, filename: str) → None

Renders and save a presentation with the given template name, values to be rendered, and filename.

Parameters:
  • template_name (str) – Name of the presentation to be saved.
  • values (dict) – Dictionary with the values to render on the template.
  • filename (str) – Name of the file to be saved.

Examples

>>> values = {'presentation_title': "My Cool Presentation"}
>>> render_and_save_ppt('template.pptx', values, 'presentation.pptx')
pypyt.render_and_save_template(template_name: str, values: dict, filename: str) → None

Renders and save a presentation with the given template name, values to be rendered, and filename.

Parameters:
  • template_name (str) – Name of the presentation to be saved.
  • values (dict) – Dictionary with the values to render on the template.
  • filename (str) – Name of the file to be saved.

Examples

>>> values = {'presentation_title': "My Cool Presentation"}
>>> render_and_save_ppt('template.pptx', values, 'presentation.pptx')
pypyt.render_chart(values: Union[dict, pandas.core.frame.DataFrame], chart: pptx.chart.chart.Chart) → None

Renders the given values into the given chart.

Parameters:
  • values (Union[dict, DataFrame]) – Values to render the chart.
  • chart (Chart) – Chart object to be rendered.
pypyt.render_paragraph(values, text_frame: pptx.text.text.TextFrame) → None

In the case you want to replace the whole text.

Parameters:
  • values (Union[dict, str, int, float]) – Values to render the text.
  • text_frame (TextFrame) – TextFrame object to be rendered.
pypyt.render_ppt(prs: <function Presentation at 0x000002185E1A9E18>, values: dict) → <function Presentation at 0x000002185E1A9E18>

Returns a rendered presentation given the template name and values to be rendered.

Parameters:
  • prs (pptx.presentation.Presentation) – Presentation to be rendered.
  • values (dict) – Dictionary with the values to render on the template.
Returns:

Rendered presentation

Return type:

pptx.presentation.Presentation

Examples

>>> prs = open_ppt('template.pptx')
>>> values = {'presentation_title': "My Cool Presentation"}
>>> render_ppt(prs, values)
<pptx.presentation.Presentation at ...>
pypyt.render_table(values: Union[dict, list, pandas.core.frame.DataFrame], table: pptx.shapes.table.Table) → None

Renders a table with the given values.

Parameters:
  • values (Union[dict, list, DataFrame]) – Values to render the table
  • table (Table) – Table object to be rendered.
pypyt.render_template(template_name: str, values: dict) → <function Presentation at 0x000002185E1A9E18>

Returns a rendered presentation given the template name and values to be rendered.

Parameters:
  • template_name (str) – Name of the presentation to be rendered.
  • values (dict) – Dictionary with the values to render on the template.
Returns:

Rendered presentation

Return type:

pptx.presentation.Presentation

Examples

>>> values = {'presentation_title': "My Cool Presentation"}
>>> render_template('template.pptx', values)
<pptx.presentation.Presentation at ...>
pypyt.save_ppt(prs: <function Presentation at 0x000002185E1A9E18>, filename: str) → None

Saves the given presentation with the given filename.

Parameters:
  • prs (pptx.presentation.Presentation) – Presentation to be saved.
  • filename (str) – Name of the file to be saved.

Examples

>>> values = {'presentation_title': "My Cool Presentation"}
>>> rendered_prs = render_template('template.pptx', values)
>>> save_ppt(rendered_prs, 'presentation.pptx')