0

So my code is:

from pptx import Presentation

prs = Presentation('template.pptx')

title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]

title.text = "Python 3.6 - Turtle Race"
subtitle.text = "Data Analytics&Visualization with random generated data"


for placeholder in prs.slide_layouts[4].placeholders:
    print('%d %s' % (placeholder.placeholder_format.idx, placeholder.name))

slide = prs.slides.add_slide(prs.slide_layouts[4])
littleTitle = slide.placeholders[1]

littleTitle.text('Comparison of Winning times and pieces of wins')

prs.save("visualiztaion.pptx")

My output is(with the error):

0 Title 1
1 Text Placeholder 2
2 Content Placeholder 3
3 Text Placeholder 4
4 Content Placeholder 5
10 Date Placeholder 6
11 Footer Placeholder 7
12 Slide Number Placeholder 8
Traceback (most recent call last):
  File "D:/!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!_!Piton/turtleRace/presentationMaker.py", line 34, in <module>
    littleTitle.text('Comparison of Winning times and pieces of wins')
TypeError: 'str' object is not callable

Process finished with exit code 1

Image of my project

You can see I have every recommended file in the project and if you want to I can send a picture of my project interpreter.

So my question is basically just how can I insert text into 0 Title 1 and into 1 Text Placeholder 2.

So mostly I just want to solve and pass the error, because I have to make this code works.

So please help me out.

Marci
  • 129
  • 1
  • 13
  • My guess is that littleTitle isn't what you think it is. Try print(type(littleTitle)) before assigning the text and see what you have. – Chris Sep 13 '19 at 13:56
  • Have you worked through the User Guide in the documentation? https://python-pptx.readthedocs.io/en/latest/index.html `Shape.text` is a property that returns a `str`; it is not a method. So you _assign_ to it to change its value, like `littleTitle.text = "Comparison of ..."` – scanny Sep 13 '19 at 19:48

0 Answers0