[PyKDE] Keeping the GUI from freezing

Dave Fancella dave at davefancella.com
Tue Feb 13 21:22:22 GMT 2007


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 at mats.imk.fraunhofer.de
> > > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde




More information about the PyQt mailing list