Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have to write an archery scoring program and I keep getting this error:
AttributeError: 'int' object has no attribute 'setText'
def main():
win = gameWindow()
currentShot, overallScore = scoreOverlay(win)
shot = 0
totalScore = 0
for i in range(5):
p = win.getMouse()
p.draw(win)
x = p.getX
y = p.getY
score = scoring(p)
currentShot.setText('Current Shot: {0:1}'.format(scoring))
overallScore = 'overallScore' + 'currentShot'
overallScore.setText('Total{0:1}'.format(overallScore))
main()
Any ideas how to fix this? I am out of my depth on this one.
Thank you in advance for any help you may be able to provide.
Here; currentShot = 0
and here; overallScore = 0
you are setting currentShot and overallScore as integers. They are no longer equal to Text(Point(175,13), 'Current Shot: ')
and Text(Point(175,340), 'Total: ')
respectively. Use different variable names for the variables in currentShot = 0
and overallScore = 0
and that should fix your error
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.