Hiding the DOS console on a console application on Windows

Bernard Yue bernie at 3captus.com
Fri Jan 25 19:15:23 EST 2002

Hi Eric,

If I understands you correctly, you have a python program (.py or .pyc) that
wants to run under windows without a console box popup when it first starts up.
If thats correct you can use pythonw.exe, instead of python.exe, in your startup
script. i.e.:

    c:\python21\bin\pythonw c:\myapp\myapp.py

Hope it helps!


Eric Brunel wrote:

> Hi all,
> We've got a problem for which we were unable to find a solution: we have an
> Windows application that communicates with a console application and that
> needs to occasionally send it a Ctrl-Break. The only way we found to do that
> was to use the Windows function "GenerateConsoleCtrlEvent" via an extension
> module. Problem: this function only works if the parent and child processes
> share the same console, so our application has to be run or built as a
> console application. That means a start-up script with a .py extension (no
> .pyw, or it doesn't work), or a build without the option suppressing the
> console (e.g., no '--noconsole' option with Gordon McMillan's installer).
> However, our application has a GUI of its own, and we need to get rid of the
> DOS console that opens automatically when our script is run. Does anybody
> know a means to hide this console? We understand that this window has to be
> created, but we just don't want to see it...
> Our application uses Python 2.1.1 with a Tkinter GUI under Windows2k.
>  - eric -

There are three schools of magic.  One:  State a tautology, then ring
the changes on its corollaries; that's philosophy.  Two:  Record many
facts.  Try to find a pattern.  Then make a wrong guess at the next
fact; that's science.  Three:  Be aware that you live in a malevolent
Universe controlled by Murphy's Law, sometimes offset by Brewster's
Factor; that's engineering.

So far as I can remember, there is not one word in the Gospels in
praise of intelligence.
                -- Bertrand Russell

More information about the Python-list mailing list