Thank you very much for the help Justin.
i followed your code on gist.
here is what i have now:
-----code----
def timer(self):
QtCore.QTimer.singleShot(100,self.export)
def export(self):
self.log.append("started")
self.proc=subprocess.Popen("avconv -i %s -b %s -s %s %s"
%(self.inputFile,self.bitRatesList[self.bitRate.currentIndex()],
self.sizeList[self.sizeSel.currentIndex()],self.outputFile),shell=True,stdout=subprocess.PIPE)
while True:
output=self.proc.stdout.readline()
if not output:
break
QtGui.qApp.processEvents()
self.log.append(output.strip())
-----code----
what is happening is the following. The self.log.append("started") only
shows when the subprocess terminates and it should be the
other way around. Also i can't append the output.strip to the
QTextBrowser(self.log) i have. it shows nicely on the terminal but not
in the GUI.
Another thing i can't figure is why i have to say to subprocess ->
Shell=True. In your code you don't have it. but if i run it that way
i get an error :
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
On 03/16/2013 03:29 AM, Justin Israel wrote:
QProcess has signals that indicate when new data is ready to read from your
process, allowing to to get line updates. Also, in your example, you are going
to be blocking the event loop with your for loop.
I put together an example of each of those for you here:
https://gist.github.com/justinfx/5174795
The first example shows how to monitor the QProcess for new output
The second shows how to use subprocess in a way that you can loop over the
output, but still pump the event loop. If your lines are being emitted quickly
you probably don't need to make the call for every loop, but rather you could
call on on every 10 lines...or 100 lines.. or whatever is appropriate to give
your main gui thread a chance to process the pending events:
i.e.
i = 0
while True:
line = process.stdout.readline()
if not line:
break
# process line
# process event loop every 10 lines
if i % 10 == 0:
QtGui.qApp.processEvents()
i +=1
-- justin
On Thursday, March 7, 2013 5:22:19 AM UTC+13, olheiros wrote:
Hi Fellas!
i'm trying to build my own video converter gui on a Linux. Using Pyqt4.
I'm using avconv command line converter.
I have setup all parameters and it is working fine.
The thing is i would like to have some kind of progress feedback.
Does anyone know how to retrieve the command line feedback so
i can hook it to some kind of expression to drive the QProgressBar?
thank you very much
--
////////////////////////////////////
Ricardo Viana
VFX Generalist
--
////////////////////////////////////
Ricardo Viana
VFX Generalist
--
You received this message because you are subscribed to the Google Groups "Python
Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.