How can I fix the scroll bug when using Windows rich edit controls in wxpython?
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?
You're close.
textctrl.SetInsertionPointEnd()
textctrl.WriteText(licence)
textctrl.SetInsertionPointEnd()
You can use the following to fix the scroll bug when using Windows rich edit controls in wxpython:
textctrl.MoveEnd()
textctrl.WriteText(text)
精彩评论