py2exe question

Alex Martelli aleax at aleax.it
Sat Nov 1 12:05:58 EST 2003


achrist at easystreet.com wrote:

> Alex Martelli wrote:
>> 
>> achrist at easystreet.com wrote:
>> 
>> > The py2exe says that a console app should have the --console option
>> > and a windows app should have the --windows option.
>> >
>> > What is the way to py2exe a python program that uses both console and
>> > windows gui?
>> > Haven't tried, but logically it should be a console -- this doesn't
>> > restrict
>> what OTHER modules you can import, it just uses the equivalent of a .py
>> script run with python.exe rather than a .pyw run with pythonw.exe, i.e.
>> a "DOS box" console does appear when the program is run.
> 
> Logically, you don't need these switches.  Outside of py2exe a *.py

Logically, maybe not, but if you have chosen to run Windows instead,
how do you avoid them?  An EXE needs to let the OS know, via switches,
if it wants a console or not -- that's all there is to it.

> gets a console and can open gui windows, a *.pyw is a pure gui

Not really: you can run either a .py or .pyw mainscript (and other
extensions yet) with either pyhon.exe or pythonw.exe.  Which EXE
you choose to run as your interpreter is the one that either gets
a console or doesn't -- because Windows associates a console (or
lack thereof) with an EXE.  By default most Python installers set
registry associations of the two extensions .py and .pyw with the
two interpreter executables in question -- that may be what's
confusing you.  But that's just a default that determines what
the Windows GUI shell is going to do when you doubleclic a file
with such an extension, etc -- you can still perfectly well run
e.g. a .pyw mainscript with python.exe from a console (e.g. so you
can see error messages, warnings etc in the console window).

> program.  Why the switches atall?  IDK?  Thought I'd ask.

The switches let you control what goes on explicitly, just as
you can control it explicitly by choosing one or the other of
the two interpreters (python.exe or pythonw.exe) at a command
prompt.  I don't know what you mean by the 'idk' question.

> I'm having a little trouble getting a py2exe executable to run on
> a machine wo python installed.  Just wondered if this has anything to
> do with it.

I don't see the connection.


Alex





More information about the Python-list mailing list