I've been googling around and trying different techniques with this for several hours, with no success so far...
I have a bash script that I wrote
to do video encoding. Now I'd like to create a GUI frontend for it. I've chosen wxPython
as my language and interface. I've completed just about everything, interface-wise, so far; now I just need for wxPython to run my script.
I know how to simply run the script, using os.system(...)
. But what I'd like to do is redirect all the output from the script (a couple pages) into a log window (specificaly, a wxTextCtrl) in my GUI, so the user can see what's going on. I may add a progress bar or something later, but the log output is far more important.
The python function popen
and its kin do something like what I want - they return a pipe or stream containing the command output - but they don't return until the script is done, which is unacceptable because the script typically takes several hours to finish; the GUI sits there unresponsive while it runs.
I've tried several other redirection methods, read lots of Python and wxWindows documentation in search of such a function; wxStreamToTextRedirector
looks almost exactly like what I need, but it does not seem to be available under wxPython (unless I'm forgetting to import something).
Ideally, the log window would be updated periodically (every second or so) to show the script's progress. I considered using some kind of idle polling event, but couldn't get anything working.
Anyone have some experience with this, or (better yet) a code sample? Any help at all would be much appreciated.