[PyQt] Working with os.popen and qprogressdialog

Andreas Pakulat apaku at gmx.de
Sun Mar 9 08:27:55 GMT 2008


On 08.03.08 22:04:57, JMiahMan wrote:
> 
> I need to create a progress bar for a command that I run with popen, but so
> far I've had no luck. Here's a sniplet of code:
> 
> Pd = QtGui.QProgressDialog ( "Creating Disk Image...", "Stop", 0, 0, self)
> 	Pd.show ()
> 	from os.path import isdir
> 	if isdir(self.foldername):
> 		changessize = self.ui.CHNGLcd.intValue()
> 		changesname = self.ui.CHNGName.text()
> 		os.popen("dd if=/dev/zero of="+str(self.foldername)+"/"+str(changesname)+"
> bs=1M count="+str(changessize)+"; sleep 5; echo 'y' | mkfs.ext3 
> "+str(self.foldername)+"/"+str(changesname)+"")
> Pd.hide()
> 
> I just want the progress bar to show up and bounce back on forth while this
> process is running but I've only gotten it at best to show up afterwards.

Thats because while you run your process the event loop is not run and
thus no painting updates are being done. I suggest to take a look at
QProcess as that one sends the output in an asynchronous way and thus
allows the event loop to update the paintings.

Andreas

-- 
You will be traveling and coming into a fortune.


More information about the PyQt mailing list