python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

condition before inserting image in placholde

Open formaforge opened this issue 1 year ago • 0 comments

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")

formaforge avatar Mar 19 '24 10:03 formaforge