-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: support applying saved theme to individual slides? #146
Comments
Hi @linzhong, can you describe your use case for us? |
Sure, I would like to create a powerpoint file using your libraray. We have some Ideally, I would like to be able to create some template slides and just Thanks, On Fri, Feb 20, 2015 at 1:49 PM, Steve Canny notifications@github.com
*Lin Zhong * Applause gets Three Straight Years as one of Forbes’ Most Promising |
As far as the themes go, the approach would be to create a starting .pptx file, a "template" of sorts, that you use as the starting point for the presentation you generate. In that starting .pptx file you would include your customized themes. You can do this by creating a presentation that uses all the themes you would like to have available and then deleting all the slides (but not the slide masters or slide layouts). You will be left with an empty presentation having multiple slide masters, each of which has its own set of slide layouts. Then you pick the particular layout you want to generate each slide, perhaps something like this: from pptx import Presentation
prs = Presentation('my-template.pptx')
slide_layout = prs.slide_masters[2].slide_layouts[3]
slide = prs.slides.add_slide(slide_layout) You'll need to know in advance what the (master_idx, layout_idx) combination is to get the theme/layout combination you're after as they are only accessible by index at the moment. Does that give you what you need? |
Thanks a lot, Steve. This indeed serve the need, I read the page you refer to earlier and knew Lin On Fri, Feb 20, 2015 at 4:03 PM, Steve Canny notifications@github.com
*Lin Zhong * Applause gets Three Straight Years as one of Forbes’ Most Promising |
Yes. The key thing here is what slide masters and slide layouts you have available to you at run time. When you add the slides having a different theme, their slide master and slide layouts are automatically added to the file too. You just don't see them unless you go looking for them in the Slide Master view. Once that's done, you get rid of the slides you added so you can start with an empty presentation. Deleting the slides does not remove the new masters and layouts. Once they're in they're there to stay unless you delete them manually. All this is done "by hand" using PowerPoint, just to get your template file configured correctly. There are other ways to do it--any method that gets the masters and layouts in there is fine--but this way is probably the quickest. What you're really looking for is how the starting presentation looks in Slide Master view. In regular Slide view mode, it should be empty when you're done. Slide Master view is also where you can figure out what the index of a particular master or layout is; just remember to start counting at 0 instead of 1. Note there is at least one other part involved, the theme{n}.xml files. Those specify the palette and fonts used by the master and layouts for that theme, and perhaps a few other details. Those get added automatically by this process. I just mention them here for anyone who might take a more direct approach :) |
This are awesome tips. Thanks! On Mon, Feb 23, 2015 at 4:34 PM, Steve Canny notifications@github.com
*Lin Zhong * Applause gets Three Straight Years as one of Forbes’ Most Promising |
No description provided.
The text was updated successfully, but these errors were encountered: