Skip to content

Turn slide layouts names to attributes#1

Merged
wikiped merged 1 commit into
masterfrom
slide_layouts_names_as_attrs
May 26, 2017
Merged

Turn slide layouts names to attributes#1
wikiped merged 1 commit into
masterfrom
slide_layouts_names_as_attrs

Conversation

@wikiped
Copy link
Copy Markdown
Owner

@wikiped wikiped commented May 26, 2017

This will add slide layouts names as attributes to SlideLayouts instance.
All layouts names will be converted to CamelCase without spaces.
If the converted name is a valid identifier and is not used already by slide_layouts instance it will be assigned as an attribute to slide_layouts.
Also all available layouts will be available (as seen in PowerPoint) as a list accessible with attribute slide_layouts.available_layouts
After that - using available layouts is as easy as accessing any other attribute.

For example with the standard template available with pptx:

pres = Presentation()
print(pres.slide_layouts.available_layouts)

Will produce:

['Title Slide', 'Title and Content', 'Section Header', 'Two Content', 'Comparison', 'Title Only', 'Blank', 'Content with Caption', 'Picture with Caption', 'Title and Vertical Text', 'Vertical Title and Text']

And using Title Slide is then as easy as:

pres.slide_layouts.TitleSlide

This will add slide layouts names as attributes to `SlideLayouts` instance.
All layouts names will be converted to CamelCase without spaces.
If the converted name is a valid identifier and is not used already by `slide_layouts` instance it will be assigned as an attribute to `slide_layouts`.
Also all available layouts will be available (as seen in PowerPoint) as a list accessible with attribute `slide_layouts.available_layouts`
After that - using available layouts is as easy as accessing any other attribute.

For example with the standard template available with `pptx`:

    pres = Presentation()
    print(pres.slide_layouts.available_layouts)

Will produce:

    ['Title Slide', 'Title and Content', 'Section Header', 'Two Content', 'Comparison', 'Title Only', 'Blank', 'Content with Caption', 'Picture with Caption', 'Title and Vertical Text', 'Vertical Title and Text']

And using `Title Slide` is then as easy as:

    pres.slide_layouts.TitleSlide
@wikiped wikiped merged commit ca29196 into master May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant