Accessing slide background in python-pptx

38 views Asked by At

It seems straightforward, but I am not able to access the slide background.

from pptx import Presentation

presentation = Presentation()
slide_layout = presentation.slide_layouts[5]  # 5 corresponds to a blank slide
slide = presentation.slides.add_slide(slide_layout)

print(slide)  # this prints: <pptx.slide.Slide object at 0x12ebbc280>

background = slide.background  # AttributeError: 'Slide' object has no attribute 'background'

When I look at the documentation, Slide object does have an attribute called background. Then why do I get the error AttributeError: 'Slide' object has no attribute 'background'?

I am using python-pptx 0.6.2. I must be doing something silly, but after some head-scratching I thought I would ask. Thank you!

0

There are 0 answers