Tkinter items question

Weil weil at sireconnect.de
Tue Apr 18 11:07:34 EDT 2000


Hello,
I'm making a little drawing tool using Tkinter, where
the user can delete the last item by right-clicking with
the mouse (and by continuing to click clean the whole
canvas). The following method (of my canvas class)
does just what I want:

def DeleteLastItem(self,event):
    items = self.find_all()
    if items:
        self.delete(items[-1])

But, I was wondering, if there is a more direct way to
access the last item other than retrieving all items first.
I could of course keep a list of all created items myself,
but that seems a bit ugly, especially as my app couldn't
use this list for anything else.
It is also not possible to just hold the last item's  id and
just decrease it when deleting. There is no guarantee,
that the ids are consecutive integers, at least when
mixing creation and and deletion of items. (I know, I've tried).

So, did I just miss the right spot in the fine manuals (even tried
that of Tk) ?
I'd appreciate any suggestions that might help me cure my
uneasiness with the above code.
Thanks.





More information about the Python-list mailing list