LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2004, 10:28 AM   #1
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Redirect script output to log window in wxPython


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.
 
Old 07-04-2004, 08:59 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Original Poster
Rep: Reputation: 48
Nevermind. I found something that seems to work. See here for what I did. Ended up using the idle event to check the output stream and update the text control.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wxPython GUI input/output simple question Hal Programming 0 04-14-2005 03:17 PM
how to redirect the output of a terminal? cpukiller Linux - Networking 5 11-10-2004 07:07 AM
How to redirect standard output of piped command to log file andrewstr Linux - General 10 02-04-2004 02:07 PM
Can I redirect script output to a file without ">> $LOGFILE" at the end of each line davee Linux - General 1 12-19-2003 05:01 AM
Ambiguous output redirect XFox Linux - Newbie 5 10-17-2003 07:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration