Im trying to start a wxPython app that (I have converted to an exe with py2exe) from a process that is running in the background.
The problem is that when the gui app opens, so does a console window (c:\windows\system\cmd.exe)
I had a look at this question where Alex Martelli suggests setting the creationflags
paramater of Popen
to 0x08000000
but this hasn't solved my problem.
Also I wonder if there is a better way of running a process in the background, at the moment I just changed the extension of the script to pyw
and since it doesn't have a GUI then it isn't visible...
This is line that calls the subprocess
subprocess.Popen(args="%s"%comPort,bufsize=0,
executable="myFrozen_WxpythonApp.exe",
creationflags=0x08000000, shell=False)
py2exe script
...
options = {'py2exe': {'compressed': 3,
'optimize': 2,
'excludes': excludes,
'packages': packages,
'dll_excludes': dll_excludes,
'bundle_files': 1,
'dist_dir': 'dist',
'xref': False,
'skip_archive': False,
'ascii': False,
#'packages': packages,
'custom_boot_script': '',
}
}
setup(options=options, windows=["app.pyw"], zipfile=None, data_files=data_files)
Update:
As I explained in my answer to this question the problem was in the subprocess.Popen
call.
The first string in the args parameter should be the name of the executable, the executable name can then be followed by any commands or data that needs to be passed to the subprocess.