Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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中的tkinter gui中运行和打开.py文件_Python_User Interface_Tkinter_Subprocess_Pycharm - Fatal编程技术网

如何在python中的tkinter gui中运行和打开.py文件

如何在python中的tkinter gui中运行和打开.py文件,python,user-interface,tkinter,subprocess,pycharm,Python,User Interface,Tkinter,Subprocess,Pycharm,我用按钮编写了一个gui,当我按下一个按钮时,我希望它运行一个显示图形的.py脚本,因此图形必须在不同的视图中打开 图形的.py文件本身运行良好,但我试图在单击按钮时将其实现到我的GUI中(我使用了Tkinter)-我使用不同的.py文件的子流程完成了此操作,但输出被保存,而不是打印在底部 因此,我不确定如何在单击按钮以在单独的窗口中打开时执行类似python test.py的测试 第二个按钮应该能够运行.py文件,但输出应该显示在文本文件中,而不是在控制台底部打印 这就是我到目前为止所做的:

我用按钮编写了一个gui,当我按下一个按钮时,我希望它运行一个显示图形的.py脚本,因此图形必须在不同的视图中打开

图形的
.py
文件本身运行良好,但我试图在单击按钮时将其实现到我的GUI中(我使用了Tkinter)-我使用不同的
.py
文件的子流程完成了此操作,但输出被保存,而不是打印在底部

因此,我不确定如何在单击按钮以在单独的窗口中打开时执行类似python test.py的测试

第二个按钮应该能够运行.py文件,但输出应该显示在文本文件中,而不是在控制台底部打印

这就是我到目前为止所做的:

        def visualise():
            #with open(" .png", "r") as output:
                command = ("python test.py")
                p = subprocess.Popen(command, shell=True)
                p.send_signal(signal.SIGINT)
                print 'completed'
buttongraph=Tkinter.Button(self,text=“生成图形”,command=visualize) buttongraph.pack()


(打印不打印,但命令不执行,我还删除了
stderr
,因为代码的输出行不工作。我只是在玩它。)

嗯,为什么要向进程发送SIGINT信号?SIGINT中断了进程…可能是@Aran Fey的复制谢谢你UUUUUUUUULOL成功了