Powerpointslide¶
flowtask.components.PowerPointSlide
¶
PowerPointSlide
¶
Bases: FlowComponent, PowerPointClient
PowerPointSlide
Overview
This component dynamically generates PowerPoint slides from a Pandas DataFrame and a .pptx template.
It supports multiple custom modes (e.g., single, double, retailer_view, overview_3up, etc.)
defined declaratively via a YAML configuration. Each mode specifies the layout and number of images per slide.
You can name your modes arbitrarily — e.g., single, double, quadruple, 1x1, retailer_block, etc.
The logic does not assume or enforce fixed names. What matters is that each mode entry in mode_content
defines a valid layout index and list of image placeholders.
The component intelligently splits grouped rows into chunks based on the selected mode’s image capacity. If there are leftover rows that don’t fill a full chunk, the component will automatically fall back to another mode with fewer images, based on availability.
Configuration Parameters (YAML):
.. table:: Properties :widths: auto
+---------------------+----------+-----------------------------------------------------------------+
| Name | Required | Summary |
+---------------------+----------+-----------------------------------------------------------------+
| template_path | Yes | Absolute path to the .pptx PowerPoint template file. |
+---------------------+----------+-----------------------------------------------------------------+
| output_file_path | Yes | Output path where the final .pptx will be saved. |
+---------------------+----------+-----------------------------------------------------------------+
| mode | Yes | Primary mode to use (e.g., double, retailer_block, etc.) |
| | | Controls the layout and chunking logic for slides. |
+---------------------+----------+-----------------------------------------------------------------+
| mode_content | Yes | Either a dict of modes, or a dict with key file pointing to a |
| | | .yaml or .json file containing the full mode structure. |
+---------------------+----------+-----------------------------------------------------------------+
Variable Masking
Text and image fields in the YAML configuration can embed dynamic variables using curly-brace syntax. These placeholders are automatically replaced at runtime using each row's values from the DataFrame.
Example: text: "{retailer} #{location_code}, {city}, {state_code}" → becomes: "Target #1234, Miami, FL"
Missing columns will leave the placeholder unresolved (e.g., {missing_key}).
Text and Image Rendering
Each images: block must define:
- an image placeholder name
- a scale_factor
- a path (can include variable masks)
- an optional nested text: block:
- placeholder_id: text placeholder where the caption will be rendered
- text: masked string
- plus optional formatting: font_size, font_color, bold, etc.
Text content shared across the slide (like headers) is defined in text_content:
and rendered using the first row in the chunk.
Grouping and Fallback Logic
- If
group_byis defined, rows will be grouped accordingly. - Each group is divided into chunks of size N, where N = number of images in the selected mode.
- Leftover rows that don’t fill a full slide are rendered using another mode that supports exactly the number of remaining images.
- The fallback is automatically selected by checking all other modes and picking the one with the largest number of images ≤ remaining.
Example mode_content (YAML snippet):
mode: double
mode_content:
# file: "slides_mode_content.yaml" (Optional, excludes following mode declarations)
single:
default_master_index: 0
default_layout_index: 1
text_content:
- "Text Placeholder 3":
text: "{retailer} | "
- "Text Placeholder 3":
text: "{category}"
font_size: 24
font_color: "808080"
bold: False
images:
- "Picture Placeholder 1":
scale_factor: 0.32 (optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 2"
text: "{retailer} #{location_code}, {city}, {state_code}"
double:
group_by: ["retailer", "category"]
default_master_index: 0
default_layout_index: 2
text_content:
- "Text Placeholder 5":
text: "{retailer} | "
- "Text Placeholder 5":
text: "{category}"
font_size: 24
font_color: "808080"
bold: False
images:
- "Picture Placeholder 2":
scale_factor: 0.32 (optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 1"
text: "{retailer} #{location_code}, {city}, {state_code}"
- "Picture Placeholder 3":
scale_factor: 0.32 (optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 4"
text: "{retailer} #{location_code}, {city}, {state_code}"
triple:
group_by: ["retailer", "category"]
default_master_index: 0
default_layout_index: 3
text_content:
- "Text Placeholder 5":
text: "{retailer} | "
- "Text Placeholder 5":
text: "{category}"
font_size: 24
font_color: "808080"
bold: False
images:
- "Picture Placeholder 2":
scale_factor: 0.32 (optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 1"
text: "{retailer} #{location_code}, {city}, {state_code}"
- "Picture Placeholder 3":
scale_factor: 0.32(optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 4"
text: "{retailer} #{location_code}, {city}, {state_code}"
- "Picture Placeholder 6":
scale_factor: 0.32(optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 7"
text: "{retailer} #{location_code}, {city}, {state_code}"
quadruple:
group_by: ["retailer", "category"]
default_master_index: 0
default_layout_index: 4
text_content:
- "Text Placeholder 5":
text: "{retailer} | "
- "Text Placeholder 5":
text: "{category}"
font_size: 24
font_color: "808080"
bold: False
images:
- "Picture Placeholder 2":
scale_factor: 0.32(optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 1"
text: "{retailer} #{location_code}, {city}, {state_code}"
- "Picture Placeholder 3":
scale_factor: 0.32(optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 4"
text: "{retailer} #{location_code}, {city}, {state_code}"
- "Picture Placeholder 6":
scale_factor: 0.32(optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 8"
text: "{retailer} #{location_code}, {city}, {state_code}"
- "Picture Placeholder 7":
scale_factor: 0.32(optional)
path: "{file_path}"
# data: "{file_data}" (optional, excludes using path)
text:
placeholder_id: "Text Placeholder 9"
text: "{retailer} #{location_code}, {city}, {state_code}"
retailer_4up:
default_layout_index: 4
...
Returns:
| Name | Type | Description |
|---|---|---|
str |
Absolute path to the saved PowerPoint presentation file. |
Raises:
| Type | Description |
|---|---|
DataNotFound
|
If the DataFrame input is empty or not provided. |
ValueError
|
If no suitable fallback layout is available for remaining records in a group. |