python在GUI的Text控件中如何实时显示运行log
本帖最后由 bilibili鹅 于 2019-11-27 14:31 编辑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控件中就显示一条
页:
[1]