os.system() on Windows in Tkinter app spawns console window
kw at codebykevin.com
Sun Aug 14 19:15:51 CEST 2011
On 8/13/11 1:15 AM, Nobody wrote:
> On Fri, 12 Aug 2011 22:49:32 -0400, Kevin Walzer wrote:
>> I'm developing a Tkinter app for a Windows customer, and the app bundles
>> several command-line tools (ported from Unix). I call out to these
>> console tools from the Tkinter app via os.system(). However, in the
>> frozen version of my app, when I call out to these tools, I get multiple
>> console windows popping up. This is jarring to say the least. Is there
>> any way to run the commands under the hood without the console/DOS
>> windows popping up?
> Just a wild guess, but try explicitly redirecting the commands'
> stdin/stdout/stderr. You might also consider using subprocess.call()
> instead of os.system().
I've gotten the CLI commands to execute silently by setting the window
flags for subprocess as discussed here:
These flags are apparently undocumented, but this solution works
perfectly. Perhaps the flags should be better documented.
Code by Kevin
More information about the Python-list