I want to add some sort of auto-text feature to an app I'm building on
top of StyledTextCtrl. For example, imagine I want to add a $ to the
end of every line, but only if there isn't already a trailing $. I
want this to happen whenever the user types, or if they paste from a
menubar, or any other way that text gets entered.
Logically, it makes sense to add a binding to EVT_STC_CHANGE so that I
can do this whenever the contents of the widget changes. However, the
documentation clearly states that the widget should not be modified
while servicing this event. So, what's the right strategy? Set up a
function which runs every 500ms to do this work? Bind to a KeyUp
(which won't work when pasting text via a menubar, for example)? ...?
I've tried doing a wx.CallAfter from within my handler for
EVT_STC_CHANGE, and that almost works, but I see the side effect that
some of my styling disappears until I jiggle the scrollbar or
otherwise cause some sort of paint event, even if I call Update or
Refresh. I'm using wxPython 2.8.12.1 on Windows, FWIW.
Thanks.