I'm trying to make a program that displays the time left on the timer using "import simplegui".
import simplegui
def timer_handler():
timer = simplegui.create_timer(500, timer_handler)
timer.start()
message = simplegui.create_timer
def draw(canvas):
canvas.draw_text(int(message, [50,112], 48, "Red")) #Line where I get the error.
frame = simplegui.create_frame("Home", 300, 200)
frame.set_draw_handler(draw)
frame.start()
You are using the timer incorrectly.
timer_handleris the function that's called every time your timer 'ticks'. You have to create the timer outside the function and then pass the handler as a parameter.As to displaying the time, you have to create a global variable and then increment it from within the handler like this: