[PyQt] widgets and references in python

victor noagbodjivictor at gmail.com
Tue Jun 29 09:50:49 BST 2010


hello list,

i have encountered an issue that i have reduced to this sample code:

if __name__ == '__main__':
    import sys
    from PyQt4.QtGui import QLabel
    from PyQt4.QtCore import QTimer
    from PyQt4.QtGui import QApplication
    app = QApplication(sys.argv)
    for i in range(3):
        l = QLabel('%d' % i)
        l.show()
    QTimer.singleShot(5000, app.quit)
    app.exec_()

because i'm using the same variable to reference the instances, only one
instance remains (the last one) which is not really what i expect.

what is the way to create several widgets in a loop? thanks.

-- 
victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100629/f244feb0/attachment.html>


More information about the PyQt mailing list