Avoiding DOS Window...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrea.gavana@agip.it

    #1

    Avoiding DOS Window...

    Hello NG,

    I don't know if this is the right place to post this question, but
    noting that it is os-related probably someone will have some nice idea.
    I have built an application using Python+wxPython , and I have compiled it
    into an exe file using py2exe. In my app, I use a call:

    self.process = os.spawnl(os.P_ NOWAIT, MyCommand)

    where MyCommand is a call to an external exe file. When I run my
    application (without the DOS window), a new DOS window is created for every
    call to os.spawnl. This is something I would like to avoid because I don't
    need to have 50 DOS windows opened on my PC. Moreover, I need to keep a
    reference to self.process, because I woule like to be able to kill the
    process when the user decides to kill it. In order to kill it, I use a
    command like:

    if self.process is not None:
    if wx.Platform == '__WXGTK__':
    try:
    status = os.kill(self.pr ocess, 9)
    except:
    pass
    else:
    try:
    win32api.Termin ateProcess(self .process,0)
    except:
    pass
    status = 0

    self.process = None

    I thought I could use os.popen* things, but it seems to me that they do not
    return something that could be killed using os.kill() or
    win32api.Termin ateProcess().
    Am I missing something about the os things? Does anyone have a better
    solution?

    Thanks to you all.

    Andrea.


    ------------------------------------------------------------------------------------------------------------------------------------------
    Message for the recipient only, if received in error, please notify the
    sender and read http://www.eni.it/disclaimer/


  • Larry Bates

    #2
    Re: Avoiding DOS Window...

    Andrea,

    Take a look at Win32 extensions CreateProcess method.
    You can control the window location/size or run
    minimized.


    win32process.Cr eateProcess(exe cute_target,
    commandLine,
    processAttribut es,
    threadAttribute s,
    bInheritHandles ,
    dwCreationFlags ,
    newEnvironment,
    currentDirector y,
    STARTUPINFO)

    Larry Bates



    andrea.gavana@a gip.it wrote:[color=blue]
    > Hello NG,
    >
    > I don't know if this is the right place to post this question, but
    > noting that it is os-related probably someone will have some nice idea.
    > I have built an application using Python+wxPython , and I have compiled it
    > into an exe file using py2exe. In my app, I use a call:
    >
    > self.process = os.spawnl(os.P_ NOWAIT, MyCommand)
    >
    > where MyCommand is a call to an external exe file. When I run my
    > application (without the DOS window), a new DOS window is created for every
    > call to os.spawnl. This is something I would like to avoid because I don't
    > need to have 50 DOS windows opened on my PC. Moreover, I need to keep a
    > reference to self.process, because I woule like to be able to kill the
    > process when the user decides to kill it. In order to kill it, I use a
    > command like:
    >
    > if self.process is not None:
    > if wx.Platform == '__WXGTK__':
    > try:
    > status = os.kill(self.pr ocess, 9)
    > except:
    > pass
    > else:
    > try:
    > win32api.Termin ateProcess(self .process,0)
    > except:
    > pass
    > status = 0
    >
    > self.process = None
    >
    > I thought I could use os.popen* things, but it seems to me that they do not
    > return something that could be killed using os.kill() or
    > win32api.Termin ateProcess().
    > Am I missing something about the os things? Does anyone have a better
    > solution?
    >
    > Thanks to you all.
    >
    > Andrea.
    >
    >
    > ------------------------------------------------------------------------------------------------------------------------------------------
    > Message for the recipient only, if received in error, please notify the
    > sender and read http://www.eni.it/disclaimer/
    >
    >[/color]

    Comment

    • fred.dixon

      #3
      Re: Avoiding DOS Window...

      Launching a subprocess without a console window



      Comment

      Working...