我编写了下面的类来在额外窗口中生成“监视”输出。
- 不幸的是,它不会自动滚动到最近的一行。有什么问题吗?
- 由于我也遇到了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!")