From pykde Mon Feb 19 16:05:17 2007 From: "Tony Cappellini" Date: Mon, 19 Feb 2007 16:05:17 +0000 To: pykde Subject: Re: [PyKDE] Keeping the GUI from freezing Message-Id: <8249c4ac0702190805u65c35d84re90963109e79560d () mail ! gmail ! com> X-MARC-Message: https://marc.info/?l=pykde&m=117190118125745 Is it not sufficient to create a timer, and have it call the main window update function? Do I really need to use threads? On 2/13/07, Dave Fancella wrote: > On Tuesday 13 February 2007 3:08 pm, Tony Cappellini wrote: > > > If your thread inherits QObject somehow, you can just do: > > > > So currently, I'm not using threads or popen. I'm using the ugly hack > > which does an exec, which was recently posted- as a work around not > > being able to catch the output of the logger. > > Oh, ok. > > > > self.emit(QtCore.SIGNAL("nameYourSignal()") ) > > > > With your reply in mind- If I need to use threads, I will probably use > > Qt threads. > > However, I don't know what signal to use in your example. > > Are you suggesting I create an arbitrary signal- not assoicated with > > any particular widget? > > Yes, you define the signal and create it thataway. You can give it arguments > too so you can pass real data. So to use it, you need somewhere else to > connect to it like you connect to any other signal. Also, you probably need > to look up the exact arguments to QObject::emit, something looks wrong about > the line I posted and I'm not placing exactly what. > > Dave > > > > > You can give arguments to it also. Then just connect slots up to the > > > signal. If your thread doesn't for some reason, then you need to give it > > > a QObject of some sort that it can call. > > > > > > Anyway, in #qt they tell me signals and slots are thread safe. I haven't > > > tested it yet, but will be testing it soon. :) > > > > > > Dave > > > > > > > Paul Giannaros ceruleanblaze at gmail.com > > > > Tue Feb 13 19:19:46 MET 2007 > > > > > > > > > Does anyone have a Python example of how to use a Thread to keep a > > > > > gui from becoming unresponsive? > > > > > > > > Well, before you turn to threads I'd suggest that there are far simpler > > > > ways to go about what you want to do. There are may ways to start a > > > > process asynchronously so that the GUI remains responsive as usual. You > > > > can use the os.popen function, for example; or the subprocess module; > > > > or Qt's QProcess. > > > > > > > > _______________________________________________ > > > > PyKDE mailing list PyKDE@mats.imk.fraunhofer.de > > > > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde > _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde