[PyQt] Working with os.popen and qprogressdialog

Andreas Pakulat apaku at gmx.de
Mon Mar 10 19:09:27 GMT 2008


On 10.03.08 08:45:43, Jeremiah Summers wrote:
> Thank you but, I'm still at a loss. I tried what the Wiki said and a
> few other pages, I've tried to understand what you said.. But as I

I'm not sure how much of the wiki is usable for a beginner, as quite
some stuff there will probably still be for PyQt3.

> said I'm pretty new at this and I learn from example. I also studied
> the class page some more, but in my reading I found that the class
> page is out of date for Qt4. I guess QProcess has dropped addAtribute.

Note sure what you were looking at but the pages you should look at are:

http://www.riverbankcomputing.com/Docs/PyQt4/html/qprocess.html
http://doc.trolltech.com/4.3/qprocess.html

> some please just post a short working script that calls a bash command
> through qprocess while displaying a progress bar for the short time
> the script runs. I need a working example to learn from sorry to be
> difficult. Thanks

The problem is that this is not a short script. Untested and not sure
about all the API:

class MyFoo(QObject):
  def startProc:
    self.progress = QProgressDialog()
    self.progress.setLabelText("Executing...")
    self.progress.show()
    self.proc = QProcess()
    connect(self.proc, SIGNAL("finished(int, QProcess::ExitStatus)"), self.procFinished)
    self.start("/usr/bin/sh -c 'ls -l /usr/share/doc '")
  def procFinished(self):
    self.progress.hide()

This should execute an ls -l /usr/share/home and show a progressbar
while that is done.  However you'll probably need to play around a bit
with escaping rules when you want to use pipes in the command.

Andreas

-- 
You will have a long and boring life.


More information about the PyQt mailing list