[PyKDE] LCD problems
fredrik danerklint
fredan-pykde at fredan.org
Wed Aug 7 19:24:01 BST 2002
Hi!
I've just start to lern python and PyQT, so this is probably an easy question
which I haven't find any solution to...
What I would like to happen is to make sure that the LCD display gets updated
from the thread. So, how do I do that?
import sys
from qt import *
class mythread(QThread):
def __init__(self,widget, *args):
self.i = 0
self.w = widget
apply(QThread.__init__, (self, ) + args)
def run(self):
while self.i < 20:
self.i = self.i + 1
self.w.LCDNumber1.display(self.i)
self.msleep(100)
print "bye from thread!"
class PlayerForm(QWidget):
def __init__(self,parent = None,name = None,fl = 0):
QWidget.__init__(self,parent,name,fl)
if name == None:
self.setName("Form1")
self.resize(417,173)
self.setCaption(self.trUtf8("Form1"))
self.LCDNumber1 = QLCDNumber(10,self,"LCDNumber1")
self.LCDNumber1.setGeometry(QRect(10,10,200,50))
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
w = PlayerForm()
t = mythread(w)
a.setMainWidget(w)
w.show()
t.start()
a.exec_loop()
t.wait()
--
//fredan
More information about the PyQt
mailing list