O'Reilly logo

Automate it! - Recipes to upskill your business by Chetan Giridhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and updating presentations, and adding slides

We continue using the python-pptx module for the recipes in this section. So, we don't have to install any new modules. We will learn how to create a blank presentation and add slides to it and, of course, some content on it.

How to do it...

  1. Let's start with a very simple example of creating a new PPT with Yo! Python written on it. The following code helps us create the presentation:
            from pptx import Presentation 
     
            prs = Presentation() 
            slide = prs.slides.add_slide(prs.slide_layouts[0]) 
            slide.shapes.title.text = "Yo, Python!" 
            slide.placeholders[1].text = "Yes it is really awesome" 
     
            prs.save('yoPython.pptx') 
    

    If we run the preceding piece of code, it will create a PPTX file with the title as Yo, Python! ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required