I am trying to make a timer which counts down to a specified time says "Click me" deletes the prompt and then continues. I'm trying to use time.sleep to keep the prompt up for 1 second then delete it but it keeps giving me an error that neither string nor int have the command delete, destroy, etc. Does anyone know why this problem is occurring. Thanks for any help in advance
from datetime import datetime
from tkinter import *
import time
tk = Tk()
canvas = Canvas(tk, width=400, height=400)
canvas.pack()
selected_date = datetime(2017,3,24,22,22)
me = Label(tk, font=('Times',45))
me.place(relx=0.5, rely=0.5, anchor=CENTER)
me.pack()
def countdown() :
s = (selected_date - datetime.now()).seconds
me['text']=str(s) + " seconds until click"
if s == 0:
text1 = str(canvas.create_text(200, 200, text="CLICK NOW", font=('Times',45)))
text1.delete()
time.sleep(1)
canvas.after(1000, countdown)
canvas.after(1000, countdown)
tk.mainloop()
Thanks for any help in advance. I am not sure why it continues to give me this error