I need to remove text from canvas after some time.
JavaScript
x
2
1
y = cnv3.create_text(600, 430, text='Authentication failed', font=('Times', 30), fill='yellow')
2
I tried this:
JavaScript
1
3
1
time.sleep(2)
2
cnv3.pack_forget(y)
3
Result: It does not even appear the text.
And this:
JavaScript
1
2
1
root.after(2000, cnv3.delete(y))
2
Not working too.
Please help, I looked almost everywhere and I didn’t find how to do that.
Advertisement
Answer
You have to give after
a reference to a function. The way you’re doing it is immediately calling the delete function and then passing the result of that to after
.
It needs to look like this:
JavaScript
1
2
1
root.after(2000, cnv3.delete, y)
2