[PyQt] QDialog's widgets do not show up correctly

Christoph Schmidt ch_schmidt at online.de
Sun Jul 6 16:19:30 BST 2008


I'm currently learning programming with PyQt and play around a bit with 
python-apt + PyQt4. My problem is as follows: In order to indicate the 
progress of an apt operation, python-apt offers the possibility to pass an 
instance of a progress class. In this case I subclassed FetchProgress from 

class GuiUpdateProgress(QDialog, FetchProgress):
    def __init__(self, parent=None):
	QDialog.__init__(self, parent)
	self.items = {}
	self.fetchIndicator = QProgressBar()
	self.speedIndicator = QLabel("Unknown")
	self.layout = QVBoxLayout()
    def start(self):
    def stop(self):
        if 2 in self.items.values():
	    QMessageBox.warning(self, "Update Error",
                                  "One or more sources could not be updated!")
    def updateStatus(self, uri, descr, shortDescr, status):
	self.items[uri] = status   # unimportant

    def pulse(self):
	self.percent = ((self.currentBytes + self.currentItems)*100.0) /
                                 float(self.totalBytes + self.totalItems)
        if self.currentCPS > 0:
            self.eta = (self.totalBytes-self.currentBytes) /
	return True
    def mediaChange(self, medium, drive):
	pass   # unimportant

When I now pass an instance of this class to a python-apt operation, at first 
start() is called, then updateStatus() and pulse() are being called 	
repeatedly until the operation is done and stop() is called in the end.

I would expect this code to let a QDialog pop up, show its initial state when 
start() is called and update whenever pulse() is called. However, it seems to 
only show an empty window before pulse() is called the first time, and even 
when pulse() is called, only the QProgressBar updates itself, the QLabel 
stays invisible.

I uploaded the a tstable version of the code at http://pastebin.com/f3caddde3 
to show you what I mean (python-apt is required). My PyQt Version is 
(according to Synaptic) 4.3.3.

I hope somebody can tell me what I am doing wrong.

Thanks in advance.

More information about the PyQt mailing list