[Py2exe-users] how to build same executabl with and without console output

Jimmy Retzlaff jimmy at retzlaff.com
Fri Jul 30 05:00:37 EDT 2010


On Fri, Jul 30, 2010 at 1:10 AM, Gelonida <gelonida at gmail.com> wrote:
> What I'd like to achieve ideally is to create a py2exe program,
> which
> will only display a window (so 'compiled' as 'windows'-application) if
> called normally.
>
> however if being called with the option --debug it should display the
> graphical window plus a debug console where I can print to.
>
> Is there any trick in adding a console window to an application,
> that was built as 'windows' application?
>
> If above is not possible:
>
> Is there any way to compile the same python script (myprog.py) from one
> py2exe script into once a 'windows' executable (myprog.exe) and once
> into a 'console' executable (myprog_debug.exe)?

I can't think of an easy way to achieve the first approach - I've
always taken the second approach. The advanced example included with
py2exe has an example of how to do this. Look at all the occurrences
of test_wx in the following link to see all the pieces involved:

http://py2exe.svn.sourceforge.net/viewvc/py2exe/trunk/py2exe/py2exe/samples/advanced/setup.py?view=markup

This uses an alternate form of the "windows" and "console" arguments
where each target is an object with specially named member variables
rather than a string that names the .py file (this string is one of
the member variables). This is necessary so you can give different
names to the console version and the windows version.

Jimmy



More information about the Python-list mailing list