[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Updating Qlabel in widget
From: uahmed <gleam.uahmed () gmail ! com>
Date: 2011-08-25 14:21:58
Message-ID: CAEUvQQy3jqFXQfciUbhEYSoqw_-613Bn8XFSudOufuAOVPz8fg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
hi
Thanks for the reply , QLabel will be created once only when count is equal
to 2 . Firstly i was thinking same that i make Qlabel first and then recall
them and change only text but if i do that then i have to create nearly
40-60 Qlabel to cover all the loop holes so i need to create it on run time
to avoid making lots of Qlabels
On Thu, Aug 25, 2011 at 3:26 PM, Hans-Peter Jansen <hpj@urpla.net> wrote:
> On Thursday 25 August 2011, 12:02:52 uahmed wrote:
> > Hi
> >
> > 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()
> > sk.f2()
> > widget.show()
> > sys.exit(app.exec_())
>
> Don't recreate the widget over and over again.
>
> Create it once, and just change the label with setText().
>
> Pete
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
[Attachment #5 (text/html)]
hi <br><br>Thanks for the reply , QLabel will be created once only when count is \
equal to 2 . Firstly i was thinking same that i make Qlabel first and then recall \
them and change only text but if i do that then i have to create nearly 40-60 Qlabel \
to cover all the loop holes so i need to create it on run time to avoid making lots \
of Qlabels<br> <br><div class="gmail_quote">On Thu, Aug 25, 2011 at 3:26 PM, \
Hans-Peter Jansen <span dir="ltr"><<a \
href="mailto:hpj@urpla.net">hpj@urpla.net</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, \
204, 204); padding-left: 1ex;"> <div><div></div><div class="h5">On Thursday 25 August \
2011, 12:02:52 uahmed wrote:<br> > Hi<br>
><br>
> I want to update the Qlabel after the widget is made , Problem is<br>
> that updating is base on counter so i call that function after 4<br>
> seconds , but when it by pass the "if" statment it go through all \
the<br> > commands give me no errors but it does not update the widet although<br>
> if i dont putt "if" statment all lines are executed and Qlabel \
update<br> > too . Can you please tell me where i am wrong<br>
><br>
> Here is code<br>
><br>
> import sys,os<br>
> from functools import partial<br>
> from PyQt4 import QtGui, QtCore<br>
> import time<br>
><br>
><br>
> class main():<br>
><br>
> def f2(self):<br>
> print "f2"<br>
> global count<br>
> count +=1<br>
> if ( count == 2):<br>
> msg_label["user"] =<br>
> QtGui.QLabel("update",widget) \
msg_label["user"].setGeometry(10, 10,<br> > 100, 100) print count<br>
> QtCore.QTimer.singleShot(4000, self.f2)<br>
><br>
><br>
> app = QtGui.QApplication(sys.argv)<br>
> widget = QtGui.QWidget()<br>
> layout = QtGui.QVBoxLayout()<br>
> buttons = {}<br>
> count = 0<br>
> msg_label = {}<br>
> sk = main()<br>
> sk.f2()<br>
> widget.show()<br>
> sys.exit(app.exec_())<br>
<br>
</div></div>Don't recreate the widget over and over again.<br>
<br>
Create it once, and just change the label with setText().<br>
<br>
Pete<br>
_______________________________________________<br>
PyQt mailing list <a \
href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br> <a \
href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" \
target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br> \
</blockquote></div><br>
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic