Using wx.execute

As a totally newbie, I’ve unsuccessfully tried to execute this example:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import wx

if __name__ == '__main__':
    app = wx.App(False) 
    pid = wx.Execute('echo S', wx.EXEC_ASYNC)

It returns pid = 0. I am using Python 3.7.5 with wxPython 4.1.0 on Windows 10. What am I missing?

Thanks in advance.

Platform and version?

Is echo an actual executable on your system, or just a command built-in to the shell program? If the latter then you would need to construct a command that runs the shell executable and passes the command line you want to execute to it as CLI parameters.

Have you looked at the Process sample in the demo?

Finally, in almost all cases using Python’s subprocess module will probably be at least a good enough solution, if not better that using wx.Process/wx.Execute.

Hi, I am using Python 3.7.5 with wxPython 4.1.0 on Windows 10. “echo” is a builtin command of the Command Window (it behaves as print).

I didn’t use Process because I wanted to show here the simplest case possible (and yet valid).

Finally, regarding subprocess, the main goal is to adapt a very long program written in Python 2 and old wx 2.8, to Python 3 and new wx. I would like to change as few parts as possible to avoid unwanted side effects in a code that I do not fully understand.