Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.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/1/cassandra/3.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运行可执行文件?_Python_Tkinter_Embed_Executable - Fatal编程技术网

Python 如何使Tkinter运行可执行文件?

Python 如何使Tkinter运行可执行文件?,python,tkinter,embed,executable,Python,Tkinter,Embed,Executable,我有一个可执行文件,我想用Tkinter运行它。如何执行此操作?在Python中,您可以使用 import os os.system("some_file.exe argument1 argument2") 但使用这种方法,您无法捕获显示的文本并在Python脚本中使用它 还有一个模块,它有许多方法来运行可执行文件和捕获文本 import subprocess subprocess.run("some_file.exe argument1 argument2", shell=True)

我有一个可执行文件,我想用Tkinter运行它。如何执行此操作?

在Python中,您可以使用

import os

os.system("some_file.exe argument1 argument2")
但使用这种方法,您无法捕获显示的文本并在Python脚本中使用它

还有一个模块,它有许多方法来运行可执行文件和捕获文本

import subprocess

subprocess.run("some_file.exe argument1 argument2", shell=True)

subprocess.run(["some_file.exe", "argument1", "argument2"])
等等


如果可执行文件将运行很长时间,那么它将停止tkinter的窗口-窗口将冻结-因此您必须使用模块在单独的线程中运行文件。

以与不使用tkinter的方式相同的方式运行它。使用模块
子进程
os.system()
或类似方法。使用
Tkinter
如果执行的文件是长时间运行的进程,您可能还必须使用
线程处理
,因为长时间运行的进程可能会停止/冻结Tkinter中的窗口。