TKinter -- '<Destroy>' event executing more than once?

Jeff Epler jepler at unpythonic.net
Sun Jun 12 09:23:04 EDT 2005


For me, an 'is' test works to find out what widget the event is taking
place on.

#------------------------------------------------------------------------
import Tkinter

def display_event(e):
    print "event received", e.widget, e.widget is t

t = Tkinter.Tk()
t.bind("<Destroy>", display_event)
w = Tkinter.Entry(t)
t.destroy()
#------------------------------------------------------------------------

This program prints:
event received .-1209415348 False
event received . True

if that fails, you could compare str(e.widget) and t._w, though this can
give a false positive if you have multiple Tk() instances---each Tk()
instance is called ".".

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050612/addf29f0/attachment.sig>


More information about the Python-list mailing list