-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateDeck.py
More file actions
53 lines (37 loc) · 1.48 KB
/
Copy pathCreateDeck.py
File metadata and controls
53 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# you will also need to install Pillow: https://pypi.org/project/Pillow:
# pip install Pillow
# added to patch bug in 3.11.3 where the following error is thrown:
# Traceback (most recent call last):
# File "C:\Users\njdem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pptx\compat\__init__.py", line 10, in <module>
# Container = collections.abc.Container
# ^^^^^^^^^^^^^^^
# AttributeError: module 'collections' has no attribute 'abc'
import collections
import collections.abc
from pptx import Presentation #install via pip install python-pptx
import os # Use PowerPoint to open our PPT
# Creating presentation object
ppt = Presentation()
# slide types
# 0 Title and subtitle
# 1 Title and content
# 2 Section header
# 3 Two content
# 4 Comparison
# 5 Title only
# 6 Blank
# 7 Content with caption
# 8 Image with caption
# Creating first slide layout
first_slide_layout = ppt.slide_layouts[0] # 0 is the slide type
# Add new slide to the deck
slide = ppt.slides.add_slide(first_slide_layout)
# Add a slide title
slide.shapes.title.text = "Created by Phthon using python-pptx"
second_slide_layout = ppt.slide_layouts[1] # 1 is the slide type
slide = ppt.slides.add_slide(second_slide_layout)
slide.shapes.title.text = "Second Slide"
# Save the new PowerPoint deck under folder where CreateDeck.py is ran
ppt.save("PythonPPT.pptx")
print("New PPT created, opening....")
os.startfile("PythonPPT.pptx")