我想用python将stdout打印到GUI。我用的是Tkinter。
这就是我为我工作的东西def get_likes_button():
output = subprocess.Popen(['python', "getLikes.py"], stdout=subprocess.PIPE)
s1 = output.stdout.read()
text.delete("1.0",END)
text.insert(INSERT,s1)
但是,我一下子就得到了全部输出。
我想要的是GUI应该迭代地打印输出,就像它在终端上打印一样。在
所以,我试过了,但是它给了我一个点击按钮的错误
^{pr2}$
错误是Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1489, in __call__
return self.func(*args)
File "gui.py", line 88, in get_likes_button
with subprocess.Popen(['python', "getLikes.py"], stdout=subprocess.PIPE) as output:
AttributeError: __exit__
你能建议我怎么做吗?在