我怎样才能在wxPython使用Windows丰富的编辑控件时,固定滚动错误?
-
27-09-2019 - |
题
在使用wx.TextCtl与Windows中的wx.TE_RICH2选项,我使用AppendText通过功能时得到这个与自动滚动奇怪的错误。它滚动,使所有的文本是可见区域,这是不很有用的行为的上方。
我尝试了追加文本之后增加ScrollLines(-1)的调用 - 这确实滚动到正确的位置 - 但是这会导致窗口闪烁时自动滚动。所以我在寻找另一种方式来自动滚动至底部。
到目前为止,我的解决办法是绕过AppendText通过功能自动滚动和实现我自己的,是这样的:
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)
有没有更好的办法?
解决方案
你靠近。
textctrl.SetInsertionPointEnd()
textctrl.WriteText(licence)
textctrl.SetInsertionPointEnd()
其他提示
您可以使用以下在wxPython使用Windows丰富的编辑控件时修复滚动错误:
textctrl.MoveEnd()
textctrl.WriteText(text)
不隶属于 StackOverflow