How to add bullet points into text box with python-pptx?

115 Views Asked by At

I have the following code which can bold certain characters on a line within a text box, but I want to add in code that will add a bullet point for the first line and then for the second line will not have a bullet point.

Right now I have two lines without bullet points.

from pptx import Presentation
from pptx.util import Inches

# Create a new presentation
prs = Presentation()

# Add a slide to the presentation
slide = prs.slides.add_slide(prs.slide_layouts[1])

# Add a text box to the slide
left = top = Inches(1)
width = height = Inches(2)
txBox = slide.shapes.add_textbox(left, top, width, height)

# Add a paragraph to the text box
tf = txBox.text_frame
p = tf.add_paragraph()

# Add text to the paragraph
run = p.add_run()
run.text = 'The'
run.font.bold = True
run.font.underline = True

run2 = p.add_run()
run2.text = ' first bullet point.'

p1 = tf.add_paragraph()
run = p1.add_run()
run.text = 'The second bullet point.s'

# Save presentation
prs.save('filename.pptx')
0

There are 0 best solutions below