I have a wxPython app which spawns child processes using the
wx.Execute command and
wx.Process class, this works as expected. However, I also need to pass along additional environment parameters to indicate the working directory for the child process. The option seems available though the
ExecuteEnv parameter as indicated by the documentation for
wx.Execute (see below).
An optional pointer to additional parameters for the child process, such as its initial working directory and environment variables. This parameter is available in wxWidgets 2.9.2 and later only.
However, I cannot figure out how to use
ExecuteEnv in this context to get the desired effect. I’ve tried instancing it but an error is raised indicating that it’s not possible. I tried passing arguments over using a
dict assuming the function takes keyword arguments similar to
Popen, however that doesn’t work.
This is how I’m presently calling
ret_val = wx.Execute(command, flags, process)
Here is what I tried with
env = wx.ExecuteEnv() # error, cannot be instanced but present in the library env["cmd"] = "path/to/working/dir" # perhaps it was suppose to work like this? doesn't though ... # tried it even like this, but also doesn't work # wx.ExecuteEnv["cmd"] = "path/to/working/dir" ret_val = wx.Execute(command, flags, process, env) # passing the environment params this time
Any suggestions or workarounds to specify the working directory (or environment) for the child process?