When using wx.TextCtl with the wx.TE_RICH2 option in windows, I get this strange bug with the auto-scroll when using the AppendText function. It scrolls so that all the text is above the visible area, which isn't very useful behaviour.
I tried just adding a call to ScrollLines(-1) after appending the text - which does scroll it to the correct position - but this can lead to the window flashing when it auto-scrolls. So I'm looking for another way to automatically scroll to the bottom.
So far, my solution is to bypass the AppendText functions auto-scroll and implement my own, like this:
def append_text(textctrl, text):
before_number_of_lines = textctrl.GetNumberOfLines()
textctrl.SetInsertionPointEnd()
textctrl.WriteText(text)
after_number_of_lines = textctrl.GetNumberOfLines()
textctrl.ScrollLines(before_number_of_lines - after_number_of_lines + 1)
Is there a better way?