[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">&lt;<a \
href="mailto:hpj@urpla.net">hpj@urpla.net</a>&gt;</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> &gt; Hi<br>
&gt;<br>
&gt; I want to update the Qlabel after the widget is made , Problem is<br>
&gt; that updating is base on counter so i call that function after 4<br>
&gt; seconds , but when it by pass the &quot;if&quot; statment it go through all \
the<br> &gt; commands give me no errors but it does not update the widet although<br>
&gt; if i dont putt &quot;if&quot; statment all lines are executed and Qlabel \
update<br> &gt; too  . Can you please tell me where i am wrong<br>
&gt;<br>
&gt; Here is code<br>
&gt;<br>
&gt; import sys,os<br>
&gt; from functools import partial<br>
&gt; from PyQt4 import QtGui, QtCore<br>
&gt; import time<br>
&gt;<br>
&gt;<br>
&gt; class main():<br>
&gt;<br>
&gt; def f2(self):<br>
&gt;                 print &quot;f2&quot;<br>
&gt;                 global count<br>
&gt;                 count +=1<br>
&gt;                 if ( count == 2):<br>
&gt;                         msg_label[&quot;user&quot;] =<br>
&gt; QtGui.QLabel(&quot;update&quot;,widget) \
msg_label[&quot;user&quot;].setGeometry(10, 10,<br> &gt; 100, 100) print count<br>
&gt;                 QtCore.QTimer.singleShot(4000, self.f2)<br>
&gt;<br>
&gt;<br>
&gt; app = QtGui.QApplication(sys.argv)<br>
&gt; widget = QtGui.QWidget()<br>
&gt; layout = QtGui.QVBoxLayout()<br>
&gt; buttons = {}<br>
&gt; count = 0<br>
&gt; msg_label = {}<br>
&gt; sk = main()<br>
&gt; sk.f2()<br>
&gt; widget.show()<br>
&gt; sys.exit(app.exec_())<br>
<br>
</div></div>Don&#39;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