MCPcopy Create free account
hub / github.com/scanny/python-pptx / PresentationPart

Class PresentationPart

src/pptx/parts/presentation.py:19–126  ·  view source on GitHub ↗

Top level class in object model. Represents the contents of the /ppt directory of a .pptx file.

Source from the content-addressed store, hash-verified

17
18
19class PresentationPart(XmlPart):
20 """Top level class in object model.
21
22 Represents the contents of the /ppt directory of a .pptx file.
23 """
24
25 def add_slide(self, slide_layout: SlideLayout):
26 """Return (rId, slide) pair of a newly created blank slide.
27
28 New slide inherits appearance from `slide_layout`.
29 """
30 partname = self._next_slide_partname
31 slide_layout_part = slide_layout.part
32 slide_part = SlidePart.new(partname, self.package, slide_layout_part)
33 rId = self.relate_to(slide_part, RT.SLIDE)
34 return rId, slide_part.slide
35
36 @property
37 def core_properties(self) -> CorePropertiesPart:
38 """A |CoreProperties| object for the presentation.
39
40 Provides read/write access to the Dublin Core properties of this presentation.
41 """
42 return self.package.core_properties
43
44 def get_slide(self, slide_id: int) -> Slide | None:
45 """Return optional related |Slide| object identified by `slide_id`.
46
47 Returns |None| if no slide with `slide_id` is related to this presentation.
48 """
49 for sldId in self._element.sldIdLst:
50 if sldId.id == slide_id:
51 return self.related_part(sldId.rId).slide
52 return None
53
54 @lazyproperty
55 def notes_master(self) -> NotesMaster:
56 """
57 Return the |NotesMaster| object for this presentation. If the
58 presentation does not have a notes master, one is created from
59 a default template. The same single instance is returned on each
60 call.
61 """
62 return self.notes_master_part.notes_master
63
64 @lazyproperty
65 def notes_master_part(self) -> NotesMasterPart:
66 """Return the |NotesMasterPart| object for this presentation.
67
68 If the presentation does not have a notes master, one is created from a default template.
69 The same single instance is returned on each call.
70 """
71 try:
72 return self.part_related_by(RT.NOTES_MASTER)
73 except KeyError:
74 notes_master_part = NotesMasterPart.create_default(self.package)
75 self.relate_to(notes_master_part, RT.NOTES_MASTER)
76 return notes_master_part

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…