python在GUI的Text控件中如何实时显示运行log
1.新建一个gui窗口from tkinter import *
root = Tk()
text = Text(root,width=200,height=150)
text.pack()
root.mainloop()2.测试函数
import logging
from time import sleep
def test():
for i in range(50):
logging.info('test log %d'%i)
sleep(1)
pr = logging.StreamHandler()
logging.basicConfig(level=logging.INFO, handlers=,
format="%(asctime)s,%(name)s,%(levelname)s : %(message)s"
)
if __name__ == '__main__':
test()
3.求大佬指导如何运行GUI时,logging中打印一条日志,Text控件中就显示一条
修改varString()即可 可以参考这篇文章看下 https://testerhome.com/topics/21431 参考下这个链接https://www.cnblogs.com/anloveslife/p/7541898.html log是打到控制台的 可以保存吧
页:
[1]