Hi,
thank you for the replies.
…but I can tell you that the same happens with wxPython 2.8.12.1 under Windows. I’ll take a look again later (time permitting).
Thank you for confirmation - if you find the time to take another look, I’d be glad.
I see it if I add “style=wx.TE_PROCESS_ENTER” to the textctrl and at
that point I can also see your problem of the carret disappearing.
You are right, I forgot to set this style - although it worked for me when I tested the script 
Instead of doing Destroy the problem goes away if you use:
styledControl.Hide()
styledControl.Close()
This works as a workaround. Although I assume the object is not freed from memory (judging by the fact that it still appears in the inspector), which could be a problem if more objects are created/closed in this way.
Does it make any difference if you put the textctrl on the panel instead of directly on the frame?
This doesn’t seem to make any difference. I discovered this while using SearchCtrl on a Toolbar, the included sample is simplified form of that.
How about if you have some other widget there and SetFocus to it before the Destroy and then set the focus back to the main textctrl after the Destroy (perhaps with CallAfter or CallLater to delay it a little)?
This, however, makes the problem disappear (even without CallAfter or CallLater). Unfortunately, the side effect is that the TextCtrl cannot be reliably typed into anymore (if the event handler would need to react for all keys, not just ENTER), since focus may take a while (although tiny) to return back which makes it miss some keys if typing reasonably fast.
So far the workaround seems to be to Hide/Close the object and collect the list of those objects for destruction once focus is in a safe place (I found that this doesn’t steal carret away from another StyledTextCtrl for example). Of course, I welcome any other ideas.
If it is a bug (and not just me doing something wrong), what would be the best place to submit it? wxWidgets tracker or does it occur only when using wxPython?
Thank you,
Pavel
···