self-closing window with wxPython

Jabba Laci jabba.laci at gmail.com
Fri Sep 17 17:00:54 EDT 2010


Hi,

> 2) I saw this in the documentation for Destroy() -- "Frames and dialogs are not destroyed immediately when this function is called -- they are added to a list of windows to be deleted on idle time, when all the window's events have been processed." That might be consistent with what you're seeing. The window you're trying to destroy has no events in its queue. WHen you move the mouse over it, the window processes those mouse events and then wx realizes, "Hey, this window has processed all of its events, and it's on the list of windows to be destroyed. I'd better get rid of it."
>
> If you're interested in experimenting, find a non-mouse way to force that window to process an event and I'll bet that would have the same effect as moving the mouse over it.

Thanks for the hint, I could solve the problem. After Destroy() I
added an extra event:

self.parent.Destroy()
self.parent.dc.SetFocus()

As you suggested, the extra event triggers the queue processing and
when it becomes empty the window gets destroyed.

Thanks,

Laszlo



More information about the Python-list mailing list