I'd like to check if a widget (such as rectangle drawn on a canvas) exists before I delete it.
Here's my problem: I have two methods that delete rectangles. One is bound to button-1 using bind (delete the rectangle when it is clicked) and the other method deletes a rectangle if it doesn't get clicked in a certain amount of time (checked using Widget.after). I would like to check if the rectangle exists in the second method because I want to count the rectangles user didn't click and the only way I can think of is check if it is already deleted. Is there a way to do this? Of course, I could set a variable inside button-1 event handler and check it from the other method. But just wanted to know if Tkinter provides method such as "item exist".
Edit : Well, I just found out one trick. If I use itemconfig on deleted widget, I get empty set. I use that value to see if a widget is already deleted or not. I'm not sure if it's an elegant way to do it though.