现在的位置: 首页 > 综合 > 正文

如何将Textctrl的滚动条保持在最后一行并且更新显示

2012年06月23日 ⁄ 综合 ⁄ 共 428字 ⁄ 字号 评论关闭

修改一个串口程序,打印信息在text区域中可以正常显示。就是满屏后,每次更新过来的信息不能自动显示出来。他总是在第一页不往下滚动;
通过google找到方法如下:

  def OnSerialRead(self, event):
        """Handle input from the serial port."""
        text = event.data
        if self.settings.unprintable:
            text = ''.join([(c >= ' ') and c or '<%d>' % ord(c)  for c in text])
        self.text_ctrl_output.AppendText(text)
        self.text_ctrl_output.ScrollLines(1)
        self.text_ctrl_output.ShowPosition(self.text_ctrl_output.GetLastPosition ())

添加上红色部分即可.

如下图,在右边的scroll bar的adjuster在最下面:

抱歉!评论已关闭.