Reply
Thread Tools
Posts: 46 | Thanked: 5 times | Joined on Sep 2009
#1
Is there any way to get a QTextBrowser to append lines read from stdout in real time?

Example (doesn't work)

Code:
proc = subprocess.Popen('/home/user/test.sh',
                               shell=True,
                               stdout=subprocess.PIPE,
                               )
for line in iter(proc.stdout.readline,''):
    self.displaybox.append(line)
    print line
This print statement works in real time, but self.displaybox doesn't append until test.sh it's done (basically a bunch of echo "foo's" with sleep 1's

Any ideas?
 
Posts: 6 | Thanked: 3 times | Joined on May 2010
#2
Originally Posted by techdork View Post
Is there any way to get a QTextBrowser to append lines read from stdout in real time?

Example (doesn't work)

Code:
proc = subprocess.Popen('/home/user/test.sh',
                               shell=True,
                               stdout=subprocess.PIPE,
                               )
for line in iter(proc.stdout.readline,''):
    self.displaybox.append(line)
    print line
One way to do this is to call the application's processEvents() method every so often. You could try calling it after you read each line, though it might be a bit inefficient to do so. The global QApplication instance is available as the qApp object, or you can obtain it using QApplication.instance().
 

The Following User Says Thank You to :-) For This Useful Post:
Posts: 46 | Thanked: 5 times | Joined on Sep 2009
#3
Originally Posted by :-) View Post
One way to do this is to call the application's processEvents() method every so often. You could try calling it after you read each line, though it might be a bit inefficient to do so. The global QApplication instance is available as the qApp object, or you can obtain it using QApplication.instance().
That is certainly and idea, thanks for the input.

On a further note, I resolved this using a QThread
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 12:54.