If I save my code files as .pyw
, no console window appears - which is what I want - but if the code includes a call to os.system
, I still get a pesky console window. I assume it's caused by the call to os.system
. Is there a way to execute other files from within my .pyw
script without raising the console window at all?
The solution that Piotr describes is actually not as complicated as it may sound. Here is an example where a startupinfo
is passed to a check_call
invocation to suppress the console window:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.check_call(cmd, startupinfo=startupinfo)
Since the convenience functions call
, check_call
, and check_output
forward their **kwargs
to the Popen
constructor, it is not required to use Popen
directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With