[PyKDE] Event loop locked on Linux PyQt 3.4

Olivier Roulet oroulet at yahoo.com
Mon Jan 20 13:05:00 GMT 2003


--- Phil Thompson <phil at river-bank.demon.co.uk> wrote:
> On Tuesday 14 January 2003 7:20 pm, Olivier Roulet
> wrote:
> > I have got the following code where I post events
> from
> > a queue every 1s .
> > On windows with qt 2.3 this works fine. On linux
> with
> > Qt 3.04 the events are not
> >  received until an  X events is send to the
> windows.
> > Is this a bug or is my code wrong ?
> 
> Without looking at the code (so this may not be
> relevant) there are problems 
> with Qt threads under Windows which (I think) were
> eventually fixed in Qt 
> 3.1.1.
> 
> Phil

The problem was not on windows but on Linux with
qt3.0.4
But OK, this weekend I upgraded to PyQt 3.45 and
qt3.1.1 and the program is running again.
maybe a bug in Qt ? 
anyway now it works
Olivier


#!/usr/bin/env python

import sys,os

from qt import *

EVENTID=QEvent.User+20
class Queue(QThread):
	def __init__(self,target):
		QThread.__init__(self)
		self.mutex=QMutex()
		self.stop=False
		self.count=0
		self.target=target
	def run(self):
		while True:
			if self.stop :
				return
			QApplication.postEvent(xv,QCustomEvent(EVENTID))
			self.msleep(1000)
	def end(self):
		self.stop=True
class XV(QMainWindow):
	def __init__(self,parent,*args):
		QMainWindow.__init__(self,*args)
		MainWidget=QWidget(self)
		self.setCentralWidget(MainWidget)
		self.label=QLabel(MainWidget)
		self.label.setText("No event so far")
		self.queue=Queue(self)
		self.queue.start()
	def customEvent(self,ev):
		if ev.type()==EVENTID:
			self.label.setText("event " + str(self.count))
			self.count=self.count+1
app=QApplication(sys.argv[1:])
xv=XV(app)
app.setMainWidget(xv)
xv.show()
app.exec_loop()
xv.queue.end() 
xv.queue.wait()


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com




More information about the PyQt mailing list