In the last post we’ve seen how to create a sort of Powepoint to make fast presentations, with no text. This time I will show you some code to make a fast presentation, with only text, but in Powepoint, using, of course, our beloved programming language (Python, in case you’re asking which is it). So… as usual, few lines to get the result and save a lot of time doing stuff. The more you save (time) the more you have to create content and other useful things in your life.
from pptx import Presentation import os def create_slides(name="slides.pptx", context=["siamo qui"]): "Create slides out of the arg list like in the example" prs = Presentation() # Iterate the list 'context' to create slides for s in context: # Choose a layout(1=normal page) layout = prs.slide_layouts[1] # add a slide with the above layout slide = prs.slides slide = slide.add_slide(layout) # give it title and content slide.shapes.title.text = s[0] slide.placeholders[1].text = s[1] prs.save(name) os.startfile(name) create_slides(name="Slides.pptx", context=[ ["Capitolo 1", "Era una notte buia e tempestosa"], ["Capitolo 2", "... e vissero felici e contenti"] ])
If you do not have it, install python-pptx with pip install python-pptx from the cmd (on windows: win button + R and then type in the pop up window ‘cmd’ without quotes.
New version… v.2 of this script
You can find a new version of this script here. So, be sure to check it, if you liked this one. There is a way to insert easily the slides in a multiline string, instead of a list (you do not have to deal with square parenthesis of apostrophes). Furthermore, you can add bullets! So go and check this script.
The new output: