Widget to Display subprocess stdout?

孤人 提交于 2019-11-29 08:48:57
Joël

You may want to use the Tkinter.Text widget, described here.

The description is quite long, but what you need to understand is mainly that this widget can be used as a buffer, as text should be inserted inside.

So, for each new line in the subprocess output, you will have to insert text where you want it. Example:

t = Tkinter.Text(root)
while some_condition:
    s = p.readline()          # get subprocess output
    t.insert(END, s)

EDIT Have a look here for getting subprocess output line by line.

You may also want to have a look to Tkinter.Scrollbar and Text.see() to tune the display.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!