Why is Pmw.Blt sending Destroy messages to my Toplevel?

Phlip phlip_cpp at my-deja.com
Thu Aug 15 11:47:10 EDT 2002

"Jeffrey Hobbs" wrote:
> Phlip wrote:
> ...
> > This really distracts because I need to bind to <Destroy> and perform
> > exit procedures. But these fire whenever Blt draws a line!
> Whenever you create a toplevel <Destroy> binding, you need to check
> that it is firing against the actual toplevel.  This is because the
> toplevel is in the bindtags of all its children, thus a <Destroy>
> that occurs for any child will propagate to the top by default.

This don't work:

def closing(event):
    if event.widget is frame:
        print 'closing!', event.type

It doesn't work because event.widget is some kind of string, while frame is
an object.

This, unfortunately, works:

def closing(event):
    if len(event.widget) == len('.12345678'):
        print 'closing!', event.type

In other words, I can tell if the widget is on top because the string
describing its address in the local window tree is short.

This sucks, but it works. Thanks for the confirmation!


More information about the Python-list mailing list