How to hide console with Popen on Windows?

Discussion in 'Python' started by xliiv, May 18, 2012.

  1. xliiv

    xliiv Guest

    1. Advertising

  2. xliiv

    Kevin Walzer Guest

    On 5/18/12 4:22 AM, xliiv wrote:
    > Like the topic, more details in followed links..
    >
    >
    > http://stackoverflow.com/questions/10637450/how-to-hide-console-with-popen-on-windows
    >
    > http://code.activestate.com/recipes/409002-launching-a-subprocess-without-a-console-window/?c=14452
    >
    > Please help :(
    > Any hint i would appreciate


    There are some Windows-specific flags in the subprocess module that you
    can set to control the display of a console window. I use something like
    this:

    self.pscmd=os.path.join(execdir, 'pstools-1.1/txt2ps.exe')
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    txtps = self.pscmd + ' -o ' + tempfile.gettempdir() +
    '\\whois.ps' + ' ' + tmpfile
    subprocess.check_output(txtps, startupinfo = startupinfo)

    Hope this helps.
    --
    Kevin Walzer
    Code by Kevin
    http://www.codebykevin.com
     
    Kevin Walzer, May 18, 2012
    #2
    1. Advertising

  3. xliiv

    alex23 Guest

    On May 18, 6:22 pm, xliiv <> wrote:
    > Like the topic, more details in followed links..
    > http://stackoverflow.com/questions/10637450/how-to-hide-console-with-...


    Try replacing all of your code with something simple, a 'pass' op will
    do. Run the script again. Does the console still open? Then it's not
    subprocess that you're struggling with.

    If I put your code into a .py file and execute it under Windows via a
    double-click, I get a console: the one in which the .py file is
    executing. Unless you're able to make the file a .pyw file - which you
    are apparently not as you're using OpenOffice - then executing the
    code that uses Popen is what is displaying a console, not the call to
    Popen itself.
     
    alex23, May 21, 2012
    #3
  4. xliiv

    xliiv Guest

    On Monday, May 21, 2012 6:38:34 AM UTC+2, alex23 wrote:
    > On May 18, 6:22 pm, xliiv <> wrote:
    > > Like the topic, more details in followed links..
    > > http://stackoverflow.com/questions/10637450/how-to-hide-console-with-....

    >
    > Try replacing all of your code with something simple, a 'pass' op will
    > do. Run the script again. Does the console still open? Then it's not
    > subprocess that you're struggling with.
    >
    > If I put your code into a .py file and execute it under Windows via a
    > double-click, I get a console: the one in which the .py file is
    > executing. Unless you're able to make the file a .pyw file - which you
    > are apparently not as you're using OpenOffice - then executing the
    > code that uses Popen is what is displaying a console, not the call to
    > Popen itself.


    Ok, thanks for explanation.
    Now I know that my 'solution' is not a solution and problem still bugs me.
    Any ideas how to deal with it?
     
    xliiv, May 21, 2012
    #4
  5. xliiv

    alex23 Guest

    On May 22, 3:00 am, xliiv <> wrote:
    > Now I know that my 'solution' is not a solution and problem still bugs me..
    > Any ideas how to deal with it?


    I haven't tried it but this thread talks about being able to use a
    standard install of Python with OpenOffice:

    http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877
     
    alex23, May 22, 2012
    #5
  6. xliiv

    xliiv Guest

    On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
    > On May 22, 3:00 am, xliiv <> wrote:
    > > Now I know that my 'solution' is not a solution and problem still bugs me.
    > > Any ideas how to deal with it?

    >
    > I haven't tried it but this thread talks about being able to use a
    > standard install of Python with OpenOffice:
    >
    > http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877


    On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
    > On May 22, 3:00 am, xliiv <> wrote:
    > > Now I know that my 'solution' is not a solution and problem still bugs me.
    > > Any ideas how to deal with it?

    >
    > I haven't tried it but this thread talks about being able to use a
    > standard install of Python with OpenOffice:
    >
    > http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877




    On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
    > On May 22, 3:00 am, xliiv <> wrote:
    > > Now I know that my 'solution' is not a solution and problem still bugs me.
    > > Any ideas how to deal with it?

    >
    > I haven't tried it but this thread talks about being able to use a
    > standard install of Python with OpenOffice:
    >
    > http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877




    On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
    > On May 22, 3:00 am, xliiv <> wrote:
    > > Now I know that my 'solution' is not a solution and problem still bugs me.
    > > Any ideas how to deal with it?

    >
    > I haven't tried it but this thread talks about being able to use a
    > standard install of Python with OpenOffice:
    >
    > http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877


    Thx for the link
    It's useful especially that:
    http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=26149
    for my walkaround of the problem.
     
    xliiv, May 22, 2012
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    1,026
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    500
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    661
    Serge Terekhoff
    Jun 30, 2003
  4. File.popen/IO.popen

    , May 20, 2006, in forum: Ruby
    Replies:
    1
    Views:
    272
    Robert Klemme
    May 20, 2006
  5. Felipe Navas

    IO.popen without console

    Felipe Navas, Jan 24, 2007, in forum: Ruby
    Replies:
    0
    Views:
    171
    Felipe Navas
    Jan 24, 2007
Loading...

Share This Page