Так как, кажется, никто не получил ответа, я хочу опубликовать решение, о котором я узнал:
import subprocess
from tkinter import *
from threading import Thread
class App(Tk):
def __init__(self):
Tk.__init__(self)
self.rowconfigure(0,weight=1)
self.columnconfigure(0,weight=1)
self.text=Text(self)
self.text.grid(row=0,column=0,sticky=NSEW)
sby=Scrollbar(self,command=self.text.yview)
sby.grid(row=0,column=1,sticky=NS)
sbx=Scrollbar(self,command=self.text.xview,orient=HORIZONTAL)
sbx.grid(row=1,column=0,sticky=EW)
self.text.config(yscrollcommand=sby.set,xscrollcommand=sbx.set)
Button(self,text='Start',command=self.callback).grid(row=2,column=0,columnspan=2,pady=5)
#creating a tkinter window with text widget to display the outputstream and start up button
self.thread=Thread(target=self.update_)
self.thread.deamon=True
#creating Thread
self.mainloop()
def callback(self):
sui=subprocess.STARTUPINFO()
sui.dwFlags|=subprocess.STARTF_USESHOWWINDOW
#setting subprocess startupflags so that ther won't be an extra shell prompt
self.prc=subprocess.Popen(('~/Python/Scripts/pyinstaller.exe', ... , '~/myprg.py'),
stdout=subprocess.PIPE,stderr=subprocess.PIPE,startupinfo=sui)
#starting subprocess with redirected stdout and stderr
self.thread.start()
def update_(self):
try:
with self.prc.stderr as pipe:
for line in iter(pipe.readline,b''): self.text.insert(END,line)
#inserting stderr output stream as is comes
finally: pass
if __name__=='__main__':
App()