<tfoot id='qRwGD'></tfoot>
      <i id='qRwGD'><tr id='qRwGD'><dt id='qRwGD'><q id='qRwGD'><span id='qRwGD'><b id='qRwGD'><form id='qRwGD'><ins id='qRwGD'></ins><ul id='qRwGD'></ul><sub id='qRwGD'></sub></form><legend id='qRwGD'></legend><bdo id='qRwGD'><pre id='qRwGD'><center id='qRwGD'></center></pre></bdo></b><th id='qRwGD'></th></span></q></dt></tr></i><div id='qRwGD'><tfoot id='qRwGD'></tfoot><dl id='qRwGD'><fieldset id='qRwGD'></fieldset></dl></div>
        <bdo id='qRwGD'></bdo><ul id='qRwGD'></ul>

      1. <legend id='qRwGD'><style id='qRwGD'><dir id='qRwGD'><q id='qRwGD'></q></dir></style></legend>
      2. <small id='qRwGD'></small><noframes id='qRwGD'>

        如何从 Python (2.7) 中生成的进程中消除 Windows 控制台?

        How do I eliminate Windows consoles from spawned processes in Python (2.7)?(如何从 Python (2.7) 中生成的进程中消除 Windows 控制台?)
            <bdo id='o2IXD'></bdo><ul id='o2IXD'></ul>
              <tbody id='o2IXD'></tbody>

              <legend id='o2IXD'><style id='o2IXD'><dir id='o2IXD'><q id='o2IXD'></q></dir></style></legend>
              <tfoot id='o2IXD'></tfoot>

              <small id='o2IXD'></small><noframes id='o2IXD'>

                <i id='o2IXD'><tr id='o2IXD'><dt id='o2IXD'><q id='o2IXD'><span id='o2IXD'><b id='o2IXD'><form id='o2IXD'><ins id='o2IXD'></ins><ul id='o2IXD'></ul><sub id='o2IXD'></sub></form><legend id='o2IXD'></legend><bdo id='o2IXD'><pre id='o2IXD'><center id='o2IXD'></center></pre></bdo></b><th id='o2IXD'></th></span></q></dt></tr></i><div id='o2IXD'><tfoot id='o2IXD'></tfoot><dl id='o2IXD'><fieldset id='o2IXD'></fieldset></dl></div>

                  本文介绍了如何从 Python (2.7) 中生成的进程中消除 Windows 控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  在没有控制台的情况下使用 Popen 在 pythonw 中运行进程

                  我在 Windows 上使用 python 2.7 使用 dcraw 和 PIL 自动进行批量 RAW 转换.

                  I'm using python 2.7 on Windows to automate batch RAW conversions using dcraw and PIL.

                  问题是我每次运行 dcraw 时都会打开一个 Windows 控制台(每隔几秒钟发生一次).如果我使用 .py 文件运行脚本,它就不会那么烦人,因为它只打开主窗口,但我更愿意只显示 GUI.

                  The problem is that I open a windows console whenever I run dcraw (which happens every couple of seconds). If I run the script using as a .py it's less annoying as it only opens the main window, but I would prefer to present only the GUI.

                  我是这样参与的:

                  args = [this.dcraw] + shlex.split(DCRAW_OPTS) + [rawfile]
                  proc = subprocess.Popen(args, -1, stdout=subprocess.PIPE)
                  ppm_data, err = proc.communicate()
                  image = Image.open(StringIO.StringIO(ppm_data))
                  

                  <小时>

                  感谢里卡多·雷耶斯


                  Thanks to Ricardo Reyes

                  对该配方的小修改,在 2.7 中,您似乎需要从 _subprocess 获取 STARTF_USESHOWWINDOW(如果您也可以使用 pywin32想要一些不太容易改变的东西),所以为了后代:

                  Minor revision to that recipe, in 2.7 it appears that you need to get STARTF_USESHOWWINDOW from _subprocess (you could also use pywin32 if you want something that might be a little less prone to change), so for posterity:

                  suinfo = subprocess.STARTUPINFO()
                  suinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
                  proc = subprocess.Popen(args, -1, stdout=subprocess.PIPE, startupinfo=suinfo)
                  

                  推荐答案

                  调用Popen时需要设置startupinfo参数.

                  You need to set the startupinfo parameter when calling Popen.

                  这是一个来自 Activestate.com 食谱的示例:

                  Here's an example from an Activestate.com Recipe:

                  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"])
                  

                  这篇关于如何从 Python (2.7) 中生成的进程中消除 Windows 控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                  <i id='1NBjh'><tr id='1NBjh'><dt id='1NBjh'><q id='1NBjh'><span id='1NBjh'><b id='1NBjh'><form id='1NBjh'><ins id='1NBjh'></ins><ul id='1NBjh'></ul><sub id='1NBjh'></sub></form><legend id='1NBjh'></legend><bdo id='1NBjh'><pre id='1NBjh'><center id='1NBjh'></center></pre></bdo></b><th id='1NBjh'></th></span></q></dt></tr></i><div id='1NBjh'><tfoot id='1NBjh'></tfoot><dl id='1NBjh'><fieldset id='1NBjh'></fieldset></dl></div>
                  <legend id='1NBjh'><style id='1NBjh'><dir id='1NBjh'><q id='1NBjh'></q></dir></style></legend>

                      <tbody id='1NBjh'></tbody>

                      • <small id='1NBjh'></small><noframes id='1NBjh'>

                          <bdo id='1NBjh'></bdo><ul id='1NBjh'></ul>
                          <tfoot id='1NBjh'></tfoot>