In all cases, cwp.py will launch a subprocess with a patched PATH env var.
The difference between pyscript and pywscript is that they will use python.exe and pythonw.exe, respectively. PythonW has the property of not creating a CMD console to launch. However, when PythonW is also used as the subprocess executable, it will kill the UI window instantly.
This is happening to us at Napari, where we can use pyscript to launch the PyQT UI perfectly (but we end up with that ugly console in the background). pywscript as it is, will launch the app but it will flash and die instantly. We've found that the following combination results in a working UI with no background console: use pythonw to call cwp.py and launch a subprocess using the regular python.exe but with a CREATE_NO_WINDOW flag.
This is what this new option pywscript_no_console implements. Documentation should be added to the Wiki as well if this is merged as it is.
Instead of new pyscript derivative, I also thought of adding a configuration parameter cwp_flags. This will allow the user to specify extra CLI flags for cwp.py, but right now there's only one (introduced in this PR), so I don't think it's too useful.
I also changed the CLI parsing to use argparse instead of that sys.argv hack.
Currently there are several ways to add a shortcut:
script
+scriptarguments
->ROOT_PYTHON ROOT/cwp.py script scriptarguments
pyscript
->ROOT_PYTHON ROOT/cwp.py ENV_PYTHON ENV_SCRIPTS/some_script.py
pywscript
->ROOT_PYTHONW ROOT/cwp.py ENV_PYTHONW ENV_SCRIPTS/some_script.py
In all cases,
cwp.py
will launch a subprocess with a patched PATH env var.The difference between
pyscript
andpywscript
is that they will usepython.exe
andpythonw.exe
, respectively. PythonW has the property of not creating a CMD console to launch. However, when PythonW is also used as the subprocess executable, it will kill the UI window instantly.This is happening to us at Napari, where we can use
pyscript
to launch the PyQT UI perfectly (but we end up with that ugly console in the background).pywscript
as it is, will launch the app but it will flash and die instantly. We've found that the following combination results in a working UI with no background console: usepythonw
to callcwp.py
and launch a subprocess using the regularpython.exe
but with aCREATE_NO_WINDOW
flag.This is what this new option
pywscript_no_console
implements. Documentation should be added to the Wiki as well if this is merged as it is.Instead of new
pyscript
derivative, I also thought of adding a configuration parametercwp_flags
. This will allow the user to specify extra CLI flags forcwp.py
, but right now there's only one (introduced in this PR), so I don't think it's too useful.I also changed the CLI parsing to use
argparse
instead of thatsys.argv
hack.