如何在Gui python中打印整个程序运行时输出

时间:2017-07-16 02:11:38

标签: python tkinter stdout

基本上我想要做的就是我想要显示在图形界面中执行的输出。 我有一个使用以下代码运行的bash脚本

from subprocess import call
myscript= call("Myscript.sh", shell=True)

现在,这个Myscript执行一些任务。我想将输出中发生的所有事情都显示给图形界面。 我试图在这里做的一些逻辑是将所有输出存储在字符串中并打印它,但它显示最终的结果和它的整数值!我希望所有字符串都打印出myscript工作。 代码如下所示:

root = Tk()
words=[]

a= call("sh amapt.sh", shell=True)
w = Label(root, text=words.append(a))
w.pack()
print w
root.mainloop()

This is my script output that i want to be displayed in a Gui somewhere as in label or form. i dont know how. im confused please guide me

1 个答案:

答案 0 :(得分:0)

{ "level":[ { "server":[ {"rank":1,"title":"The Shawshank Redemption"}, {"rank":2,"title":"The Godfather"}, {"rank":3,"title":"The Godfather: Part II"}, {"rank":4,"title":"The Dark Knight"} ] } ] } 返回退出代码,这是一个整数值。试试call,它会返回文字。

check_output
相关问题