0

I am trying to create a simple console programm in python which shall accept arguments. For the testing purpose I have created a simple python programm using python v2.7 on Windows 7 OS, that just prints the argument passed by the user.

Code:

#!/usr/bin/env

import sys
print ' +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n'
print ' |                                             |\n'
print ' +            Testing      v1.0                +\n'
print ' +           Copyright (C) 2014                +\n'
print ' |                                             |\n'
print ' +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n'
print sys.argv

After this is created an executable using py2exe. The executable is created successfully!

Setup.py used for creating the executable using py2exe:

#!/usr/bin/python
'''
This script is used to create an executable from wxPython code
'''
from distutils.core import setup
import py2exe

setup (
    name='test',
    description="Testing 4 fun",
    version="0.1",
    windows=[{'script': 'test.py'}],#
    platforms=["any"],
    options={ 'py2exe': {
                        "compressed": 2, 
                        "optimize": 2,
                        "bundle_files": 3,
                        }
             },
    )

But when I execute my executable it doesn't displays the cmd console window at all. I would like the console window to appear. How can I make it possible?

Well one solution would be to create a GUI with wxPython and then create an executable. Is there any alternative that doesn't requires any GUI programming?

ρss
  • 5,115
  • 8
  • 43
  • 73
  • Does it not show the console at all, or does it just flash the console too fast for you to read what's on it? – Cody Piersall Nov 21 '14 at 15:47
  • I tried to add the `time.sleep(5)` but the console never appears. So, I think the console never appears. I would really appreciate it if you please try this your system and report it. I'll add the setup.py file code also in my question. – ρss Nov 21 '14 at 15:49

1 Answers1

3

Use console instead of windows:

console=['test.py'],
FogleBird
  • 74,300
  • 25
  • 125
  • 131
  • I shall admit that I didn't look up the docs. As soon as I saw your answer I recalled that it was really a simple solution. Thanks and nice weekend! – ρss Nov 21 '14 at 15:56