sbi*_*rch 17 python console user-interface popen pythonw
我有一个带有GUI的程序,通过Popen调用运行外部程序:
p = subprocess.Popen("<commands>" , stdout=subprocess.PIPE , stderr=subprocess.PIPE , cwd=os.getcwd())
p.communicate()
Run Code Online (Sandbox Code Playgroud)
但是无论我做什么,都会弹出控制台(我也尝试将NUL传递给文件句柄).如果没有得到我调用的二进制文件来释放它的控制台,有没有办法做到这一点?
int*_*jay 31
从这里:
import subprocess
def launchWithoutConsole(command, args):
"""Launches 'command' windowless and waits until finished"""
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return subprocess.Popen([command] + args, startupinfo=startupinfo).wait()
if __name__ == "__main__":
# test with "pythonw.exe"
launchWithoutConsole("d:\\bin\\gzip.exe", ["-d", "myfile.gz"])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10125 次 |
| 最近记录: |