[PyQt] Updating Qlabel in widget

uahmed gleam.uahmed at gmail.com
Thu Aug 25 11:02:52 BST 2011


I want to update the Qlabel after the widget is made , Problem is that
updating is base on counter so i call that function after 4 seconds , but
when it by pass the "if" statment it go through all the commands give me no
errors but it does not update the widet although if i dont putt "if"
statment all lines are executed and Qlabel update too  . Can you please tell
me where i am wrong

Here is code

import sys,os
from functools import partial
from PyQt4 import QtGui, QtCore
import time

class main():

def f2(self):
                print "f2"
                global count
                count +=1
                if ( count == 2):
                        msg_label["user"] = QtGui.QLabel("update",widget)
                        msg_label["user"].setGeometry(10, 10, 100, 100)
                        print count
                QtCore.QTimer.singleShot(4000, self.f2)

app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
layout = QtGui.QVBoxLayout()
buttons = {}
count = 0
msg_label = {}
sk = main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110825/6d1bdaa2/attachment.html>

More information about the PyQt mailing list