[wxPython-users] Deleting a text control from an EVT_TEXT_ENTER

Andrea Gavana andrea.gavana at gmail.com
Tue Jul 17 14:34:20 PDT 2007


Hi Anthony,

On 7/17/07, Anthony M. Floyd wrote:

<snip>
<snap>

> What is causing the crash?  I suspect there's another event that follows
> the EVT_TEXT_ENTER event, but I don't understand why this isn't handled
> cleanly by the "safe" .Destroy() method.
>
> How can we deal with this?  Anyone have any suggestions?  At the moment,
> rather than running Destroy(), the controls are being hidden and
> appended to a list in the parent, and during an EVT_IDLE handler the
> controls in this list are destroyed.  This works ok, but doesn't seem
> "clean".

Try to use something like:

wx.CallAfter(theTextCtrl.Destroy)

or:

wx.CallLater(200, theTextCtrl.Destroy)

It should work with wx.CallAfter, as this method is somewhat supposed
to wait that all the events have been processed before calling the
target function (Destroy()).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/




More information about the wxpython-users mailing list