Python tkinter中的子进程,运行.exe文件

Python tkinter中的子进程,运行.exe文件,python,tkinter,Python,Tkinter,我的代码: import subprocess for file in ('folder_with_all_files'): a= subprocess.Popen(['my_exe_file.exe',file,'command'],shell=True, stderr=subprocess.STDOUT,stdout=subprocess.PIPE)\ communicate()[0] 通常在.py脚本中一切正常。但是当我试图把这些行放到tkinter中时,什么都没有发生 Tkin

我的代码:

import subprocess

for file in ('folder_with_all_files'):
  a= subprocess.Popen(['my_exe_file.exe',file,'command'],shell=True, stderr=subprocess.STDOUT,stdout=subprocess.PIPE)\ communicate()[0] 
通常在
.py
脚本中一切正常。但是当我试图把这些行放到
tkinter
中时,什么都没有发生

Tkinter的一部分
代码:

 def Run():
      for file in ('folder_with_all_files'):
        a= subprocess.Popen(['my_exe_file.exe',file,'command'],shell=True, 
        stderr=subprocess.STDOUT,stdout=subprocess.PIPE)\ communicate()[0]


    button.configure(command=RUN)
我做错了什么?以及如何仅选择要使用的文件的特定扩展名,例如:.dat only 谢谢

编辑:我也尝试过:

def Run():
  filenames=os.listdir('folder_with_all_files') 
  for file in filenames:
    a= subprocess.Popen(['my_exe_file.exe',file,'command'],shell=True, 
    stderr=subprocess.STDOUT,stdout=subprocess.PIPE)\ communicate()[0]
即使在我向文件添加直接路径时也不起作用

a= subprocess.Popen(['my_exe_file.exe','direct path/file','command']

但仍然不起作用

问题与文件有关,我只显示了文件夹的路径,程序不知道应该使用哪些文件

a= subprocess.Popen(['my_exe_file.exe','direct path/file','command']
这行代码帮助我解决了问题,并获得了文件的特定扩展名:

filenames= glob.glob(os.path.join('path',"*.xxx"))

为“文件夹中的文件(包含所有文件)”干杯:将为
f
运行一次命令,为
o
运行一次命令,为
l
运行一次命令,依此类推-您正在迭代字符串的字符。@jasonharper请查看我的编辑帖子