[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  
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.connect(self.gcenter, QtCore.SIGNAL("clicked()"),self.count)
		guiLayout = QtGui.QGridLayout()

	def count(self):
		n = 0
		step = 1
		while True:
			n += step
			print n

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

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  

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! 

More information about the PyQt mailing list