[PyQt] thread in pyqt ... simple example needed

massimo di stefano massimodisasha at yahoo.it
Sun Apr 5 18:56:59 BST 2009


Hi All,

i'm doing my first experience using pyqt and tring to learn more about  
it
unlucky i'm not able to solve some problems by myself :-(
i googled a lot about and i tried to use QTassistant
....
but i'm pretty new to programming and i've some difficoult to learn.

i tried to resume my problem in a sample script, that is :


import sys
from PyQt4 import QtCore, QtGui
import time

class Gui(QtGui.QWidget):
	def __init__(self, parent=None):
		QtGui.QGroupBox.__init__(self, parent)
		self.gcenter = QtGui.QPushButton("X", self)
		self.gcenter.setAutoRepeat(True)
		self.connect(self.gcenter, QtCore.SIGNAL("clicked()"),self.count)
		guiLayout = QtGui.QGridLayout()
		guiLayout.addWidget(self.gcenter,1,0)
		self.setLayout(guiLayout)


	def count(self):
		n = 0
		step = 1
		while True:
			n += step
			print n
			time.sleep(0.5)


if __name__ == "__main__":
	app = QtGui.QApplication(sys.argv)
	gui = Gui()
	gui.show()
	sys.exit(app.exec_())



as you can see the gui do not exit from the "while" statment
and it freeze ...
i know, i need to learn more about QTrhead usage...
an example on how to change the previouse code, will give me a great  
help!

thanks for help me !!!





Massimo Di Stefano
massimodisasha at yahoo.it

epifanio on   irc.freenode.net  /join gfoss







Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 



More information about the PyQt mailing list