Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to hide console with Popen on Windows?

1,653 views
Skip to first unread message

xliiv

unread,
May 18, 2012, 4:22:26 AM5/18/12
to

Kevin Walzer

unread,
May 18, 2012, 7:09:02 AM5/18/12
to
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

alex23

unread,
May 21, 2012, 12:38:34 AM5/21/12
to
On May 18, 6:22 pm, xliiv <tymoteusz.jankow...@gmail.com> 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.

xliiv

unread,
May 21, 2012, 1:00:26 PM5/21/12
to
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?

alex23

unread,
May 21, 2012, 8:45:11 PM5/21/12
to
On May 22, 3:00 am, xliiv <tymoteusz.jankow...@gmail.com> 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

xliiv

unread,
May 22, 2012, 11:59:04 AM5/22/12
to
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.


0 new messages