scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.26k stars 498 forks source link

condition before inserting image in placholde #960

Open formaforge opened 3 months ago

formaforge commented 3 months ago

0

I use python-pptx library maintained by scanny. I have already manually inserted the placeholders in the Powerpoint template in the layout and not in the slide. I am looking for the python code equivalent of "placeholder is not in use". I want to be sure that the placeholder does not contain any elements before inserting an image. In other hand,this is also in the case where if I want to replace the picture contained in the placeholder with a new picture. In my case it's picture placeholder.the problem can also arise for inserting a chart or a table. Is there any way to find a solution? Thank you so much

Here is the snippet concerned:

for placeHolder in slide.placholders:
    if placeHolder.name ="myplaceholder" and "placeholder is not in use":
        image = placeHolder.insert_picture("myimage.jpg")