Turn slide layouts names to attributes#1
Merged
Conversation
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will add slide layouts names as attributes to
SlideLayoutsinstance.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_layoutsinstance it will be assigned as an attribute toslide_layouts.Also all available layouts will be available (as seen in PowerPoint) as a list accessible with attribute
slide_layouts.available_layoutsAfter that - using available layouts is as easy as accessing any other attribute.
For example with the standard template available with
pptx:Will produce:
And using
Title Slideis then as easy as: