我编写了以下类,用于在额外的窗口中生成“监视”输出。

  • 不幸的是,它不会自动向下滚动到最新行。怎么了?
  • 由于Tkinter和ipython也有问题,qt4的等效实现看起来如何?

  • 这是代码:
    import Tkinter
    class Monitor(object):
      @classmethod
      def write(cls, s):
        try:
          cls.text.insert(Tkinter.END, str(s) + "\n")
          cls.text.update()
        except Tkinter.TclError, e:
          print str(s)
      mw = Tkinter.Tk()
      mw.title("Message Window by my Software")
      text = Tkinter.Text(mw, width = 80, height = 10)
      text.pack()
    

    用法:
    Monitor.write("Hello World!")
    

    最佳答案

    在一个调用插入语句之后立即添加一个语句cls.text.see(Tkinter.END)

    关于python - 如何在Tkinter消息窗口中自动滚动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/811532/

    10-11 22:32
    查看更多