Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python脚本仅在我关闭控制台时工作_Python_Tkinter_Stdout_Popen - Fatal编程技术网

python脚本仅在我关闭控制台时工作

python脚本仅在我关闭控制台时工作,python,tkinter,stdout,popen,Python,Tkinter,Stdout,Popen,我使用Tkinter创建一个接口,将脚本连接到解释器,解释器的角色是运行这些脚本。我正在使用子流程模块popen(),它工作正常,但运行结果显示在控制台窗口中。我尝试将结果重定向到界面中的文本区域,但控制台窗口仍会弹出,但这次它是空的,只有在我关闭控制台窗口后,结果才会显示在此文本区域。 谁能帮我找出我做错了什么? 先谢谢你 def interpreter1(): b=que2.get(block=True) a=que1.get(block=True)

我使用Tkinter创建一个接口,将脚本连接到解释器,解释器的角色是运行这些脚本。我正在使用子流程模块popen(),它工作正常,但运行结果显示在控制台窗口中。我尝试将结果重定向到界面中的文本区域,但控制台窗口仍会弹出,但这次它是空的,只有在我关闭控制台窗口后,结果才会显示在此文本区域。 谁能帮我找出我做错了什么? 先谢谢你

 def interpreter1():
        b=que2.get(block=True)
        a=que1.get(block=True)
        print "prameters are :" ,a ,b ,"\r\n"
        c='python C:\\workspace\\Project_Interpreter\\Tool-v1.0.py -s %s %s'%(b,a)
        ps=sp.Popen(['cmd','/K',c] , creationflags=0, shell=False, stdout=PIPE,stderr=sp.STDOUT,stdin=PIPE)
        texte01= ps.stdout.readlines()

您可以使用subprocess.STARTUPINFO类从控制台窗口隐藏文本。它可以作为一个选项传递给subprocess.Peopen()。试试这个:

def interpreter1():
        b=que2.get(block=True)
        a=que1.get(block=True)
        print "prameters are :" ,a ,b ,"\r\n"
        c='python C:\\workspace\\Project_Interpreter\\Tool-v1.0.py -s %s %s'%(b,a)
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        ps=sp.Popen(['cmd','/K',c] , creationflags=0, shell=False, startupinfo=startupinfo, stdout=PIPE, stderr=sp.STDOUT, stdin=PIPE)
        texte01= ps.stdout.readlines()