From: Tim Golden on
On 27/07/2010 15:58, Brian Curtin wrote:
> On Tue, Jul 27, 2010 at 09:36,<python(a)bdurham.com> wrote:
>
>> Windows: How can I detect whether a Python app/script is running in
>> console/GUI mode? By app I mean a script compiled to an exe via py2exe or
>> similar.
>>
>> Thank you,
>> Malcolm
>>
>
> I don't remember much about py2exe, but you could check if
> ``os.path.split(sys.executable)[1]`` equals pythonw.exe (typical for GUIs)
> or just python.exe (regular console).

Don't know whether it's foolproof, but I suspect that
checking whether win32console.GetConsoleWindow ()
returns zero is probably not a bad approach.

TJG