我编写了以下类,用于在额外的窗口中生成“监视”输出。
这是代码:
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/