Python 如何使Tkinter运行可执行文件?
我有一个可执行文件,我想用Tkinter运行它。如何执行此操作?在Python中,您可以使用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)
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中的窗口。