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

Werner F. Bruhin werner.bruhin at free.fr
Wed Jul 18 10:48:43 PDT 2007


Hi Anthony,

Anthony M. Floyd wrote:
> Hi Werner,
>
> [snip]
>
>   
>>    def DestroyTextCtrl(self, control):
>>         sizer = control.GetContainingSizer()
>>         if sizer:
>>             sizer.Detach(control)
>>         wx.CallAfter(control.Destroy)
>>     
>
> Thanks, yes that does work too.  Of course, when I tried to implement
> it, it was still crashing, but that's when I noticed that the callback
> was control.Destroy and not control.Destroy().
with wx.CallAfter you always do this.

e.g. if the callback had params you would do

wx.CallAfter(yourcallbackwithoutbrackets, params)
>   When using the
> unbracketed case, I don't need to detach it from the sizer before
> destroying it.
>   
I didn't even try it without as I saw your post that CallAfter was not 
working.

I then thought that the sizer might not like it having a window pulled 
away from him and as sizers give hard crashes in some cases I just 
thought this was another one.

It would be nice if wx.CallAfter would not give a hard crash if one puts 
the ()
> Thanks,
>   
Your welcome
Werner




More information about the wxpython-users mailing list