繁体   English   中英

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

[英]Subprocess in tkinter, running .exe file

我的代码:

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谢谢

编辑:我也尝试过:

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']

但仍然行不通

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

这行代码帮助我解决了问题,并获得了文件的特定扩展名:

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

干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM