How to hide console with Popen on Windows?

K

Kevin Walzer


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.
 
A

alex23


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.
 
X

xliiv

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?
 
X

xliiv

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

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



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



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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top