tppt
¶
🐍 🛡️ Typed Python PowerPoint Tool 🛡️ 🐍¶
import tppt ( ... tppt.Presentation.builder() ... .slide( ... lambda slide: slide.BlankLayout() ... .builder() ... .text( ... "Hello, World!", ... left=(1, "in"), ... top=(1, "in"), ... width=(5, "in"), ... height=(2, "in"), ... ) ... ) ... .build() ... .save("simple.pptx") ... )
Attributes¶
__version__ = importlib.metadata.version('tppt')
module-attribute
¶
T = TypeVar('T')
module-attribute
¶
P = ParamSpec('P')
module-attribute
¶
Classes¶
Functions¶
apply(func: Callable[Concatenate[T, P], T], *args: P.args, **kwargs: P.kwargs) -> Callable[[T], T]
¶
Partially applies the given function func with arguments args and keyword arguments kwargs,
returning a new function that takes only the first argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[Concatenate[T, P], T]
|
A function that takes a first argument of type |
required |
*args
|
args
|
Variable positional arguments to partially apply to |
()
|
**kwargs
|
kwargs
|
Variable keyword arguments to partially apply to |
{}
|
Returns:
| Type | Description |
|---|---|
Callable[[T], T]
|
A function that takes a single argument |
Source code in src/tppt/__init__.py
Modules¶
exception
¶
Classes¶
TpptException
¶
Bases: Exception
Base exception for tppt.
Source code in src/tppt/exception.py
ColorInvalidFormatError
¶
ColorInvalidTupleSizeError
¶
SlideLayoutIndexError
¶
Bases: TpptException, IndexError
Slide layout index is out of range.
Source code in src/tppt/exception.py
SlideMasterAttributeMustBeSlideLayoutError
¶
Bases: TpptException, ValueError
Slide master attribute must be a slide layout.
Source code in src/tppt/exception.py
SlideMasterDoesNotHaveAttributesError
¶
Bases: TpptException, AttributeError
Slide master does not have an attribute.
Source code in src/tppt/exception.py
SlideMasterAttributeNotFoundError
¶
Bases: TpptException, AttributeError
Slide master attribute not found.
Source code in src/tppt/exception.py
InvalidSetterTypeError
¶
Bases: TpptException, TypeError
Invalid setter type.
Source code in src/tppt/exception.py
InvalidColorValueError
¶
Bases: TpptException, ValueError
Invalid color value.
Source code in src/tppt/exception.py
pptx
¶
📊 python-pptx wrapper implementation 📊¶
This module provides a wrapper for the python-pptx library.
In addition, the Presentation and SlideLayout classes have a builder() method, which allows you to create a PowerPoint declaratively.
Classes¶
Modules¶
action
¶
ActionSetting
¶
Bases: PptxConvertible[ActionSetting]
Source code in src/tppt/pptx/action.py
chart
¶
chart
¶LiteralChartType = Literal['3D Area', '3D Stacked Area', '3D 100% Stacked Area', '3D Clustered Bar', '3D Stacked Bar', '3D 100% Stacked Bar', '3D Column', '3D Clustered Column', '3D Stacked Column', '3D 100% Stacked Column', '3D Line', '3D Pie', '3D Exploded Pie', 'Area', 'Stacked Area', '100% Stacked Area', 'Clustered Bar', 'Bar of Pie', 'Stacked Bar', '100% Stacked Bar', 'Bubble', 'Bubble with 3D effects', 'Clustered Column', 'Stacked Column', '100% Stacked Column', 'Clustered Cone Bar', 'Stacked Cone Bar', '100% Stacked Cone Bar', '3D Cone Column', 'Clustered Cone Column', 'Stacked Cone Column', '100% Stacked Cone Column', 'Clustered Cylinder Bar', 'Stacked Cylinder Bar', '100% Stacked Cylinder Bar', '3D Cylinder Column', 'Clustered Cylinder Column', 'Stacked Cylinder Column', '100% Stacked Cylinder Column', 'Doughnut', 'Exploded Doughnut', 'Line', 'Line with Markers', 'Stacked Line with Markers', '100% Stacked Line with Markers', 'Stacked Line', '100% Stacked Line', 'Pie', 'Exploded Pie', 'Pie of Pie', 'Clustered Pyramid Bar', 'Stacked Pyramid Bar', '100% Stacked Pyramid Bar', '3D Pyramid Column', 'Clustered Pyramid Column', 'Stacked Pyramid Column', '100% Stacked Pyramid Column', 'Radar', 'Filled Radar', 'Radar with Data Markers', 'High-Low-Close', 'Open-High-Low-Close', 'Volume-High-Low-Close', 'Volume-Open-High-Low-Close', '3D Surface', 'Surface (Top View)', 'Surface (Top View wireframe)', '3D Surface (wireframe)', 'Scatter', 'Scatter with Lines', 'Scatter with Lines and No Data Markers', 'Scatter with Smoothed Lines', 'Scatter with Smoothed Lines and No Data Markers']
module-attribute
¶ChartProps
¶
Bases: TypedDict
Chart properties.
Source code in src/tppt/pptx/chart/chart.py
chart_type: LiteralChartType | XL_CHART_TYPE
instance-attribute
¶x: Length | LiteralLength
instance-attribute
¶y: Length | LiteralLength
instance-attribute
¶cx: Length | LiteralLength
instance-attribute
¶cy: Length | LiteralLength
instance-attribute
¶chart_data: PptxChartData
instance-attribute
¶ChartData
¶Chart
¶to_pptx_chart_type(chart_type: XL_CHART_TYPE | LiteralChartType) -> XL_CHART_TYPE
¶Source code in src/tppt/pptx/chart/chart.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
converter
¶
Type definitions for pptx wrapper.
PT = TypeVar('PT')
module-attribute
¶PptxAngle: TypeAlias = float
module-attribute
¶PptxConvertible
¶
Bases: Generic[PT]
Protocol for objects that can be converted to and from pptx objects.
Source code in src/tppt/pptx/converter.py
to_pptx_length(length: Length | LiteralLength | PptxLength | None) -> PptxLength | None
¶Source code in src/tppt/pptx/converter.py
to_tppt_length(length: PptxLength | None) -> Length | None
¶to_pptx_rgb_color(color: Color | LiteralColor | PptxRGBColor | None) -> tuple[PptxRGBColor, int | None] | None
¶Source code in src/tppt/pptx/converter.py
to_tppt_rgb_color(color: PptxRGBColor | None, alpha: int | None) -> Color | None
¶to_pptx_angle(angle: Angle | LiteralAngle | None) -> PptxAngle | None
¶to_tppt_angle(angle: PptxAngle | None) -> Angle | None
¶
dml
¶
Drawing Markup Language wrapper implementation.
color
¶LiteralThemeColor = Literal['accent1', 'accent2', 'accent3', 'accent4', 'accent5', 'accent6', 'background1', 'background2', 'dark1', 'dark2', 'followed_hyperlink', 'hyperlink', 'light1', 'light2', 'text1', 'text2', 'mixed']
module-attribute
¶ColorFormat
¶
Bases: PptxConvertible[ColorFormat]
Source code in src/tppt/pptx/dml/color.py
brightness: float
property
writable
¶Read/write float value between -1.0 and 1.0 indicating the brightness adjustment for this color, e.g. -0.25 is 25% darker and 0.4 is 40% lighter. 0 means no brightness adjustment.
rgb: Color
property
writable
¶theme_color: MSO_THEME_COLOR | None
property
writable
¶Theme color value of this color.
Value is a member of :ref:MsoThemeColorIndex, e.g.
MSO_THEME_COLOR.ACCENT_1. Raises AttributeError on access if the
color is not type MSO_COLOR_TYPE.SCHEME. Assigning a member of
:ref:MsoThemeColorIndex causes the color's type to change to
MSO_COLOR_TYPE.SCHEME.
set_brightness(value: float) -> Self
¶set_rgb(color: Color | LiteralColor | PptxRGBColor) -> Self
¶set_theme_color(value: LiteralThemeColor | MSO_THEME_COLOR | None) -> Self
¶Set theme color value and return self for method chaining.
to_pptx_theme_color(value: LiteralThemeColor | MSO_THEME_COLOR | None) -> MSO_THEME_COLOR
¶Source code in src/tppt/pptx/dml/color.py
effect
¶ShadowFormat
¶
Bases: PptxConvertible[ShadowFormat]
Source code in src/tppt/pptx/dml/effect.py
fill
¶FillFormat
¶
Bases: PptxConvertible[FillFormat]
Fill format.
Source code in src/tppt/pptx/dml/fill.py
Fill
¶
Bases: PptxConvertible[_GenericPptxFill]
GradFill
¶
Bases: Fill[_GradFill]
Gradient fill.
Source code in src/tppt/pptx/dml/fill.py
NoFill
¶PattFill
¶
Bases: Fill[_PattFill]
Pattern fill.
Source code in src/tppt/pptx/dml/fill.py
GradientStops
¶
Bases: PptxConvertible[_GradientStops]
Gradient stops.
Source code in src/tppt/pptx/dml/fill.py
GradientStop
¶
Bases: PptxConvertible[_GradientStop]
Gradient stop.
Source code in src/tppt/pptx/dml/fill.py
color: ColorFormat
property
¶Color.
position: float
property
writable
¶Location of stop in gradient path as float between 0.0 and 1.0.
The value represents a percentage, where 0.0 (0%) represents the start of the path and 1.0 (100%) represents the end of the path. For a linear gradient, these would represent opposing extents of the filled area.
line
¶LineFormat
¶
Bases: PptxConvertible[LineFormat]
Line format.
Source code in src/tppt/pptx/dml/line.py
enum
¶
dml
¶LiteralLineDashStyle = Literal['dash', 'dash_dot', 'dash_dot_dot', 'long_dash', 'long_dash_dot', 'round_dot', 'solid', 'square_dot', 'mixed']
module-attribute
¶LiteralPatternType = Literal['cross', 'dark_downward_diagonal', 'dark_horizontal', 'dark_upward_diagonal', 'dark_vertical', 'dashed_downward_diagonal', 'dashed_horizontal', 'dashed_upward_diagonal', 'dashed_vertical', 'diagonal_brick', 'diagonal_cross', 'divot', 'dotted_grid', 'downward_diagonal', 'horizontal', 'horizontal_brick', 'large_checker_board', 'large_confetti', 'large_grid', 'light_downward_diagonal', 'light_horizontal', 'light_upward_diagonal', 'light_vertical', 'narrow_horizontal', 'narrow_vertical', 'outlined_diamond', '5%_of_the_foreground_color', '10%_of_the_foreground_color', '20%_of_the_foreground_color', '25%_of_the_foreground_color', '30%_of_the_foreground_color', '40%_of_the_foreground_color', '50%_of_the_foreground_color', '60%_of_the_foreground_color', '70%_of_the_foreground_color', '75%_of_the_foreground_color', '80%_of_the_foreground_color', '90%_of_the_foreground_color', 'plaid', 'shingle', 'small_checker_board', 'small_confetti', 'small_grid', 'solid_diamond', 'sphere', 'trellis', 'upward_diagonal', 'vertical', 'wave', 'weave', 'wide_downward_diagonal', 'wide_upward_diagonal', 'zig_zag', 'mixed']
module-attribute
¶to_pptx_line_dash_style(dash_style: LiteralLineDashStyle | MSO_LINE_DASH_STYLE | None) -> MSO_LINE_DASH_STYLE | None
¶Source code in src/tppt/pptx/enum/dml.py
to_pptx_pattern_type(pattern_type: LiteralPatternType | MSO_PATTERN_TYPE) -> MSO_PATTERN_TYPE
¶Source code in src/tppt/pptx/enum/dml.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
notes_slide
¶
NotesSlide
¶
presentation
¶
Presentation wrapper implementation.
Presentation
¶
Bases: PptxConvertible[Presentation]
Presentation wrapper with type safety.
Source code in src/tppt/pptx/presentation.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
core_properties: _PptxCorePropertiesPart
property
¶Get the core properties.
notes_master: NotesMaster
property
¶Get the notes master.
slides: list[Slide]
property
¶Get the slides.
slide_master: SlideMaster
property
¶Get the slide master.
This tool supports only one slide master.
slide_width: Length | None
property
writable
¶slide_height: Length | None
property
writable
¶tree: dict[str, Any]
property
¶Get the node tree of the presentation.
__init__(pptx: _PptxPresentation | FilePath) -> None
¶Initialize presentation.
Source code in src/tppt/pptx/presentation.py
set_slide_width(value: Length | LiteralLength) -> Self
¶set_slide_height(value: Length | LiteralLength) -> Self
¶PresentationBuilder
¶
Bases: Generic[GenericTpptSlideMaster]
Builder for presentations.
Source code in src/tppt/pptx/presentation.py
__init__(slide_master: type[GenericTpptSlideMaster]) -> None
¶Initialize the builder.
Source code in src/tppt/pptx/presentation.py
slide_width(value: Length | LiteralLength) -> Self
¶slide_height(value: Length | LiteralLength) -> Self
¶slide(slide: Callable[[type[GenericTpptSlideMaster]], SlideLayout | SlideBuilder]) -> Self
¶Add a slide to the presentation.
Source code in src/tppt/pptx/presentation.py
build() -> Presentation
¶NotesMaster
¶
Bases: _BaseMaster
Notes master.
Source code in src/tppt/pptx/presentation.py
shape
¶
Shape wrapper implementation.
GenericPptxBaseShape = TypeVar('GenericPptxBaseShape', bound=PptxBaseShape, default=PptxBaseShape)
module-attribute
¶GenericPptxShape = TypeVar('GenericPptxShape', bound=PptxShape, default=PptxShape)
module-attribute
¶BaseShape
¶
Bases: PptxConvertible[GenericPptxBaseShape]
Source code in src/tppt/pptx/shape/__init__.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
click_action: ActionSetting
property
¶element: PptxShapeElement
property
¶height: Length
property
writable
¶left: Length
property
writable
¶name: str
property
writable
¶part: PptxBaseSlidePart
property
¶placeholder_format: PptxPlaceholderFormat
property
¶rotation: float
property
writable
¶shadow: ShadowFormat
property
¶shape_id: int
property
¶shape_type: MSO_SHAPE_TYPE
property
¶top: Length
property
writable
¶width: Length
property
writable
¶__eq__(other: object) -> bool
¶__ne__(other: object) -> bool
¶set_height(value: Length | LiteralLength | PptxLength) -> Self
¶set_left(value: Length | LiteralLength | PptxLength) -> Self
¶set_name(value: str) -> Self
¶set_rotation(value: float) -> Self
¶set_top(value: Length | LiteralLength | PptxLength) -> Self
¶set_width(value: Length | LiteralLength | PptxLength) -> Self
¶Shape
¶
Bases: BaseShape[GenericPptxShape]
Source code in src/tppt/pptx/shape/__init__.py
SubShape
¶RangeProps
¶
Bases: TypedDict
Range properties.
Source code in src/tppt/pptx/shape/__init__.py
background
¶Background
¶
Bases: PptxConvertible[_Background]
Background of the slide.
Source code in src/tppt/pptx/shape/background.py
picture
¶MOVIE_MIME_TYPE = Literal['video/x-ms-asf', 'video/avi', 'video/quicktime', 'video/mp4', 'video/mpeg', 'video/msvideo', 'video/x-ms-wmv', 'video/x-msvideo']
module-attribute
¶PictureProps
¶
Bases: TypedDict
Picture properties.
Source code in src/tppt/pptx/shape/picture.py
PictureData
¶Picture
¶MovieProps
¶MovieData
¶to_pptx_movie_mime_type(mime_type: MOVIE_MIME_TYPE) -> str
¶Convert movie mime type to pptx movie mime type.
Source code in src/tppt/pptx/shape/picture.py
text
¶TextProps
¶
Bases: RangeProps
Text properties.
Source code in src/tppt/pptx/shape/text.py
size: NotRequired[Length | LiteralLength]
instance-attribute
¶bold: NotRequired[bool]
instance-attribute
¶italic: NotRequired[bool]
instance-attribute
¶color: NotRequired[Color | LiteralColor]
instance-attribute
¶margin_bottom: NotRequired[Length | LiteralLength]
instance-attribute
¶margin_left: NotRequired[Length | LiteralLength]
instance-attribute
¶vertical_anchor: NotRequired[MSO_ANCHOR]
instance-attribute
¶word_wrap: NotRequired[bool]
instance-attribute
¶auto_size: NotRequired[MSO_AUTO_SIZE]
instance-attribute
¶alignment: NotRequired[PP_ALIGN]
instance-attribute
¶level: NotRequired[int]
instance-attribute
¶TextData
¶Text
¶
Bases: Shape
Text data class.
Source code in src/tppt/pptx/shape/text.py
text_frame: TextFrame
property
¶__init__(pptx_obj: PptxShape, data: TextData | None = None) -> None
¶Source code in src/tppt/pptx/shape/text.py
slide
¶
Slide wrapper implementation.
Slide
¶
Bases: _BaseSlide[Slide]
Slide wrapper with type safety.
Source code in src/tppt/pptx/slide.py
follow_master_background: bool
property
¶notes_slide: NotesSlide | None
property
¶Get the notes slide.
placeholders: list[SlidePlaceholder]
property
¶Get all placeholders in the slide.
shapes: list[BaseShape]
property
¶Get all shapes in the slide.
slide_id: int
property
¶Get the slide id.
slide_layout: SlideLayout
property
¶Get the slide layout.
SlideBuilder
¶Slide builder.
Source code in src/tppt/pptx/slide.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
__init__(slide_layout: SlideLayout, placeholder_registry: Callable[[Slide], None]) -> None
¶Source code in src/tppt/pptx/slide.py
text(text: str | Callable[[Text], Text], /, **kwargs: Unpack[TextProps]) -> Self
¶Source code in src/tppt/pptx/slide.py
picture(image: FilePath | IO[bytes] | Callable[[Picture], Picture], image_file: FilePath | IO[bytes] | None = None, **kwargs: Unpack[PictureProps]) -> Self
¶Source code in src/tppt/pptx/slide.py
movie(movie: FilePath | IO[bytes] | Callable[[Movie], Movie], /, movie_file: FilePath | IO[bytes] | None = None, **kwargs: Unpack[MovieProps]) -> Self
¶Source code in src/tppt/pptx/slide.py
table(data: DataFrame | Callable[[Table], Table], /, rows: int | None = None, cols: int | None = None, **kwargs: Unpack[TableProps]) -> Self
¶Source code in src/tppt/pptx/slide.py
chart(data: Callable[[Chart], Chart] | None = None, /, **kwargs: Unpack[ChartProps]) -> Self
¶Source code in src/tppt/pptx/slide.py
add_shape(shape_type: MSO_AUTO_SHAPE_TYPE, shape: Callable[[Shape], Shape] | None = None, /, **kwargs: Unpack[RangeProps]) -> Self
¶Add a shape to the slide.
Source code in src/tppt/pptx/slide.py
slide_layout
¶
SlideLayout
¶
Bases: PptxConvertible[SlideLayout]
Slide layout data class.
Source code in src/tppt/pptx/slide_layout.py
name: str | None
property
¶String representing the internal name of this slide.
Returns an empty string if no name is assigned.
background: Background
property
¶Get the background.
placeholders: list[LayoutPlaceholder]
property
¶Get the placeholders.
shapes: list[BaseShape]
property
¶Get the shapes.
slide_master
¶
SlideMaster
¶
Bases: PptxConvertible[SlideMaster]
Slide master data class.
Source code in src/tppt/pptx/slide_master.py
table
¶
cell
¶Cell
¶
Bases: PptxConvertible[_Cell]
Cell data class.
Source code in src/tppt/pptx/table/cell.py
fill: FillFormat
property
¶Fill format.
is_merge_origin: bool
property
¶True if this cell is the top-left grid cell in a merged cell.
is_spanned: bool
property
¶True if this cell is spanned by a merge-origin cell.
margin_left: Length
property
writable
¶Left margin of cells.
margin_right: Length
property
writable
¶Right margin of cell.
margin_top: Length
property
writable
¶Top margin of cell.
margin_bottom: Length
property
writable
¶Bottom margin of cell.
span_height: int
property
¶int count of rows spanned by this cell.
span_width: int
property
¶int count of columns spanned by this cell.
text: str
property
writable
¶Textual content of cell as a single string.
text_frame: TextFrame
property
¶Text frame of cell.
vertical_anchor: MSO_VERTICAL_ANCHOR | None
property
writable
¶Vertical alignment of this cell.
merge(other_cell: Cell) -> None
¶table
¶Table wrapper implementation.
logger = logging.getLogger(__name__)
module-attribute
¶DataFrame: TypeAlias = list[list[str]] | list[Dataclass] | list[PydanticModel] | PandasDataFrame | PolarsDataFrame | PolarsLazyFrame
module-attribute
¶TableCellStyle
¶
Bases: TypedDict
Table cell style properties.
Source code in src/tppt/pptx/table/table.py
text_align: NotRequired[Literal['left', 'center', 'right', 'justify']]
instance-attribute
¶vertical_align: NotRequired[Literal['top', 'middle', 'bottom']]
instance-attribute
¶bold: NotRequired[bool]
instance-attribute
¶italic: NotRequired[bool]
instance-attribute
¶font_size: NotRequired[Points | LiteralPoints]
instance-attribute
¶font_name: NotRequired[str]
instance-attribute
¶TableProps
¶TableData
¶Table
¶
Bases: PptxConvertible[Table]
Table data class.
Source code in src/tppt/pptx/table/table.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
__init__(pptx_obj: PptxTable, props: TableData | None = None) -> None
¶Source code in src/tppt/pptx/table/table.py
dataframe2list(data: DataFrame) -> list[list[str]]
¶Convert different DataFrame types to list of lists.
Source code in src/tppt/pptx/table/table.py
text
¶
font
¶Font
¶
Bases: PptxConvertible[Font]
Source code in src/tppt/pptx/text/font.py
name: str | None
property
writable
¶size: Length | None
property
writable
¶bold: bool | None
property
writable
¶italic: bool | None
property
writable
¶underline: bool | MSO_TEXT_UNDERLINE_TYPE | None
property
writable
¶color: ColorFormat
property
writable
¶set_name(name: str) -> Font
¶set_size(size: Length) -> Font
¶set_bold(bold: bool) -> Font
¶set_italic(italic: bool) -> Font
¶set_underline(underline: bool | MSO_TEXT_UNDERLINE_TYPE) -> Font
¶hyperlink
¶Hyperlink
¶
Bases: PptxConvertible[_Hyperlink]
Source code in src/tppt/pptx/text/hyperlink.py
paragraph
¶Paragraph
¶
Bases: PptxConvertible[_Paragraph]
Source code in src/tppt/pptx/text/paragraph.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
alignment: PP_PARAGRAPH_ALIGNMENT | None
property
writable
¶font: Font
property
¶level: int
property
writable
¶line_spacing: int | float | Length | None
property
writable
¶runs: tuple[Run, ...]
property
¶space_after: Length | None
property
writable
¶space_before: Length | None
property
writable
¶text: str
property
writable
¶add_line_break() -> None
¶add_run() -> Run
¶set_alignment(value: PP_PARAGRAPH_ALIGNMENT | None) -> Self
¶clear() -> None
¶set_level(value: int) -> Self
¶set_line_spacing(value: int | float | Length | PptxLength | None) -> Self
¶set_space_after(value: Length | PptxLength | None) -> Self
¶set_space_before(value: Length | PptxLength | None) -> Self
¶run
¶Run
¶
Bases: PptxConvertible[_Run]
Source code in src/tppt/pptx/text/run.py
text_frame
¶TextFrame
¶
Bases: SubShape[TextFrame]
Source code in src/tppt/pptx/text/text_frame.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
auto_size: MSO_AUTO_SIZE | None
property
writable
¶margin_bottom: EnglishMetricUnits
property
writable
¶margin_left: EnglishMetricUnits
property
writable
¶margin_right: EnglishMetricUnits
property
writable
¶margin_top: EnglishMetricUnits
property
writable
¶paragraphs: tuple[Paragraph, ...]
property
¶text: str
property
writable
¶vertical_anchor: MSO_VERTICAL_ANCHOR | None
property
writable
¶word_wrap: bool | None
property
writable
¶__init__(pptx_obj: PptxTextFrame) -> None
¶add_paragraph() -> Paragraph
¶set_auto_size(value: MSO_AUTO_SIZE | None) -> Self
¶clear() -> None
¶fit_text(font_family: str = 'Calibri', max_size: int = 18, bold: bool = False, italic: bool = False, font_file: str | None = None) -> None
¶set_margin_bottom(value: Length | LiteralLength | PptxLength) -> Self
¶set_margin_left(value: Length | LiteralLength | PptxLength) -> Self
¶set_margin_right(value: Length | LiteralLength | PptxLength) -> Self
¶set_margin_top(value: Length | LiteralLength | PptxLength) -> Self
¶set_text(text: str) -> Self
¶set_vertical_anchor(value: MSO_VERTICAL_ANCHOR | None) -> Self
¶
tree
¶
color_format_to_dict(color_format: Any) -> dict[str, Any]
¶Convert color format to dictionary
Source code in src/tppt/pptx/tree.py
text_frame_to_dict(text_frame: Any) -> dict[str, Any]
¶Convert text frame to dictionary
Source code in src/tppt/pptx/tree.py
shape_to_dict(shape: BaseShape) -> dict[str, Any]
¶Convert Shape object to dictionary
Source code in src/tppt/pptx/tree.py
placeholder_to_dict(placeholder: Any) -> dict[str, Any]
¶Convert placeholder to dictionary
Source code in src/tppt/pptx/tree.py
slide_layout_to_dict(slide_layout: Any) -> dict[str, Any]
¶Convert slide layout to dictionary
Source code in src/tppt/pptx/tree.py
slide_master_to_dict(slide_master: Any) -> dict[str, Any]
¶Convert slide master to dictionary
Source code in src/tppt/pptx/tree.py
slide_to_dict(slide: Slide) -> dict[str, Any]
¶Convert slide to dictionary
Source code in src/tppt/pptx/tree.py
ppt2tree(ppt: PptxPresentation) -> dict[str, Any]
¶Convert presentation information to dictionary
Source code in src/tppt/pptx/tree.py
template
¶
Modules¶
default
¶
DefaultTitleSlideLayout
¶
Bases: SlideLayout
Title slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶subtitle: Placeholder[str | None] = None
class-attribute
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultTitleAndContentSlideLayout
¶
Bases: SlideLayout
Title and content slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶content: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultSectionHeaderSlideLayout
¶
Bases: SlideLayout
Section header slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶text: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultTwoContentSlideLayout
¶
Bases: SlideLayout
Two content slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶left_content: Placeholder[str]
instance-attribute
¶right_content: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultComparisonSlideLayout
¶
Bases: SlideLayout
Comparison slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶left_title: Placeholder[str]
instance-attribute
¶left_content: Placeholder[str]
instance-attribute
¶right_title: Placeholder[str]
instance-attribute
¶right_content: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultTitleOnlySlideLayout
¶
Bases: SlideLayout
Title only slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultBlankSlideLayout
¶DefaultContentWithCaptionSlideLayout
¶
Bases: SlideLayout
Content with caption slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶content: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultPictureWithCaptionSlideLayout
¶
Bases: SlideLayout
Picture with caption slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶picture_path: Placeholder[FilePath]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultTitleAndVerticalTextSlideLayout
¶
Bases: SlideLayout
Title and vertical text slide layout.
Source code in src/tppt/template/default.py
title: Placeholder[str]
instance-attribute
¶vertical_text: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None] = None
class-attribute
instance-attribute
¶footer: Placeholder[str | None] = None
class-attribute
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultVerticalTitleAndTextSlideLayout
¶
Bases: SlideLayout
Vertical title and text slide layout.
Source code in src/tppt/template/default.py
vertical_title: Placeholder[str]
instance-attribute
¶text: Placeholder[str]
instance-attribute
¶date: Placeholder[datetime.date | None]
instance-attribute
¶footer: Placeholder[str | None]
instance-attribute
¶slide_number: Placeholder[Literal['‹#›'] | int | None] = None
class-attribute
instance-attribute
¶DefaultSlideMaster
¶
Bases: SlideMaster
Source code in src/tppt/template/default.py
TitleLayout: Layout[DefaultTitleSlideLayout]
instance-attribute
¶TitleAndContentLayout: Layout[DefaultTitleAndContentSlideLayout]
instance-attribute
¶SectionHeaderLayout: Layout[DefaultSectionHeaderSlideLayout]
instance-attribute
¶TwoContentLayout: Layout[DefaultTwoContentSlideLayout]
instance-attribute
¶ComparisonLayout: Layout[DefaultComparisonSlideLayout]
instance-attribute
¶TitleOnlyLayout: Layout[DefaultTitleOnlySlideLayout]
instance-attribute
¶BlankLayout: Layout[DefaultBlankSlideLayout]
instance-attribute
¶ContentWithCaptionLayout: Layout[DefaultContentWithCaptionSlideLayout]
instance-attribute
¶PictureWithCaptionLayout: Layout[DefaultPictureWithCaptionSlideLayout]
instance-attribute
¶TitleAndVerticalTextLayout: Layout[DefaultTitleAndVerticalTextSlideLayout]
instance-attribute
¶VerticalTitleAndTextLayout: Layout[DefaultVerticalTitleAndTextSlideLayout]
instance-attribute
¶
slide_layout
¶
AnyType = TypeVar('AnyType')
module-attribute
¶Placeholder
¶Source code in src/tppt/template/slide_layout.py
SlideLayout
¶Base class for slide layouts
Source code in src/tppt/template/slide_layout.py
__init__(**kwargs) -> None
¶Source code in src/tppt/template/slide_layout.py
__get__(instance: object | None, objtype: type[Any]) -> type[Self] | Self
¶SlideLayoutProxy
¶Source code in src/tppt/template/slide_layout.py
__init__(slide_layout: type[SlideLayout], convertible_slide_layout: PptxConvertibleSlideLayout) -> None
¶__call__(*args: Any, **kwargs: Any) -> Any
¶__getattr__(item: str) -> Any
¶builder() -> SlideBuilder
¶Source code in src/tppt/template/slide_layout.py
get_placeholders(slide_layout: SlideLayout) -> OrderedDict[str, str | datetime.date | None | Callable[[SlidePlaceholder], SlidePlaceholder]]
¶Source code in src/tppt/template/slide_layout.py
slide_master
¶
GenericSlideMaster = TypeVar('GenericSlideMaster', bound='type[SlideMaster]')
module-attribute
¶GenericTpptSlideMaster = TypeVar('GenericTpptSlideMaster', bound=SlideMaster)
module-attribute
¶SlideMaster
¶Layout
¶Source code in src/tppt/template/slide_master.py
SlideMasterProxy
¶Source code in src/tppt/template/slide_master.py
__init__(origin: type[SlideMaster], presentation: Presentation) -> None
¶__getattr__(key: str) -> SlideLayoutProxy
¶Source code in src/tppt/template/slide_master.py
slide_master(source: Literal['default'] | FilePath) -> Callable[[GenericSlideMaster], GenericSlideMaster]
¶Decorator that sets the slide master source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Literal['default'] | FilePath
|
Either "default" or a path to a PowerPoint file containing the slide master |
required |
Source code in src/tppt/template/slide_master.py
get_slide_layouts(slide_master: type[SlideMaster]) -> OrderedDict[str, type[SlideLayout]]
¶Get an array of slides tagged with Layout.
Source code in src/tppt/template/slide_master.py
tool
¶
Tool module for TPPT.
Modules¶
ppt2template
¶
Tool to generate slide master and layout type definitions from PowerPoint.
formatter_class = RichHelpFormatter
module-attribute
¶parser = argparse.ArgumentParser(description='Generate slide master and layout type definitions from PowerPoint', formatter_class=formatter_class)
module-attribute
¶args = parser.parse_args()
module-attribute
¶PlaceholderInfo
dataclass
¶Information about a placeholder.
Source code in src/tppt/tool/ppt2template.py
name: str
instance-attribute
¶type: int
instance-attribute
¶field_name: str | None = None
class-attribute
instance-attribute
¶field_type: str | None = None
class-attribute
instance-attribute
¶required: bool = False
class-attribute
instance-attribute
¶idx: int | None = None
class-attribute
instance-attribute
¶__init__(name: str, type: int, field_name: str | None = None, field_type: str | None = None, required: bool = False, idx: int | None = None) -> None
¶LayoutInfo
dataclass
¶Information about a slide layout.
Source code in src/tppt/tool/ppt2template.py
MasterInfo
dataclass
¶Information about a slide master.
Source code in src/tppt/tool/ppt2template.py
extract_master_info(tree: dict[str, Any]) -> MasterInfo
¶Extract information about the slide master and its layouts.
Source code in src/tppt/tool/ppt2template.py
clean_field_name(name: str) -> str
¶Clean a field name to make it suitable for a Python identifier.
Removes numeric suffixes, converts to snake_case, and handles special characters.
Source code in src/tppt/tool/ppt2template.py
analyze_layout(layout: LayoutInfo) -> LayoutInfo
¶Analyze layout and determine class name and field information.
Source code in src/tppt/tool/ppt2template.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
generate_layout_class(layout: LayoutInfo) -> str
¶Generate Python code for a slide layout class.
Source code in src/tppt/tool/ppt2template.py
generate_master_class(master: MasterInfo) -> str
¶Generate Python code for a slide master class.
Source code in src/tppt/tool/ppt2template.py
analyze_slide_structure(pptx_path: tppt.types.FilePath) -> dict[str, Any]
¶Analyzes slide master and layout information from a PowerPoint file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pptx_path
|
FilePath
|
Path to the PowerPoint file |
required |
Source code in src/tppt/tool/ppt2template.py
generate_template_file(pptx_path: tppt.types.FilePath, *, output_path: tppt.types.FilePath | None = None) -> None
¶Generates slide master and layout definitions from a PowerPoint file and saves them as a Python file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pptx_path
|
FilePath
|
Path to the PowerPoint file |
required |
output_path
|
FilePath | None
|
Path to save the generated Python file (default: prints to standard output) |
None
|
Source code in src/tppt/tool/ppt2template.py
ppt2tree
¶
Tool to convert PowerPoint to tree structure JSON.
formatter_class = RichHelpFormatter
module-attribute
¶parser = argparse.ArgumentParser(description='Convert PPTX to tree structure JSON', formatter_class=formatter_class)
module-attribute
¶args = parser.parse_args()
module-attribute
¶save_ppt_tree(pptx_path: tppt.types.FilePath, *, pretty: bool = False, output_path: tppt.types.FilePath | None = None) -> None
¶Convert PPTX file to tree structure and save as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pptx_path
|
FilePath
|
Path to the PPTX file |
required |
output_path
|
FilePath | None
|
Path to save the JSON file (default: same as PPTX with .json extension) |
None
|