pythonturtle-graphicspython-turtle

'_Screen' object has no attribute 'onTimer'


For some reason my code that was working perfectly fine suddenly stopped working when I opened up my project today, here is my snippet of code that is not working.

import turtle
running = True
wn = turtle.Screen()
TimeTurtle = turtle.Turtle()

def setTime():
    global Time
    global running
    if running:
        Time = Time + 1
        TimeTurtle.clear()
    TimeTurtle.write("Time: " + str(Time), align="center", font=("Arial", 15, "bold"))
    wn.onTimer(setTime, 1000)

I get the error: '_Screen' object has no attribute 'onTimer' Any help?


Solution

  • wn.onTimer(setTime, 1000)
    

    I don't see an onTimer method listed anywhere in the turtle documentation. Perhaps you want ontimer, with a lowercase T?

    wn.ontimer(setTime, 1000)