[Python] Placeholder for pictures in python-pptx

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I want to make a presentation with python-pptx with 3 pictures in a row on each slide.

    from pptx import Presentation
    from pptx.util import Inches

    height = Inches(3) #size
    top = Inches(0) #y-position

    img = 'image001.png'

    prs = Presentation() #create presentation
    blank_slide_layout = prs.slide_layouts[6] #define side layout


    for j in range(0,5):
    slide = prs.slides.add_slide(blank_slide_layout) #add slide
    left = Inches(0) #x-position
    for i in range(0,3):
    pic = slide.shapes.add_picture(img, left, top, height=height)
    left = left+height

    prs.save('test.pptx')



    This here is working but i want to understand the placeholders. I need first to fill the first (left) picture at each slide and jump back to the first slide and all second (mid) pictures and the same for the third column because i am loading the pics from a txt-file.

    The txt file look like

    pic1a
    pic2a
    pic3a
    pic1b
    pic2b
    ...


    and i need the pics in the presentation like

    pic1a pic1b pic1c
    pic2a..
    pic3a...


    How can i add placeholders and jump to them. The manual is not helping me.

    Continue reading...

Compartilhe esta Página