[PyKDE] Window refresh from another process

Albert Cervera Areny informatic at sedifa.com
Thu Jul 3 12:15:01 BST 2003


Hi!
  I'm trying to do something like the semaphore.py example, but I can't
use QThread (can't import QThread from qt, how should I do this?). I
don't know if this is the problem but I'm using Thread and after the
QApplication.postEvent() (semaphore.py uses QThread.postEvent() ) I've
tried calling app.processEvents() (app is a global name for my
QApplication). However, the customEvent() isn't called.

Do you know how I could solve this?

> On Wednesday 02 July 2003 4:47 pm, Albert Cervera Areny wrote:
>> > On Wed, Jul 02, 2003 at 12:07:56PM +0200, Albert Cervera Areny wrote:
>> >> >>   The problem is that when the event occurs the window isn't
>> >>
>> >> refreshed
>> >>
>> >> >> until I move the mouse cursor. The XML-RPC process calls the
>> window
>> >> >> addEvent function (I've written) and the last thing it does is
>> >>
>> >> calling
>> >>
>> >> >> self.repaint(0) but it doesn't work.
>> >> >>
>> >> >>   Does somebody have a clue of how I could solve this?
>> >> >
>> >> > Is self.update() any better?
>> >>
>> >> No. It's exactly the same
>> >
>> > I suppose that you're running the XML-RPC server at one thread and the
>> > graphic front-end at another. If that's the case, are you aware that
>> you
>> > can't simply update the graphics from the XML-RPC thread, but only
>> from
>> > the main, graphics, thread (it is, if you want immediate results)?
>> It's
>> > the same you can see with Java's SWING, and others.
>>
>> Then, how could I do this? The XML-RPC server is blocking and can't
>> think
>> how I could make it run in the same thread.
>> Another possibility would be repainting from the GUI thread, I imagine,
>> but I can't see how could I do this at regular intervals once the
>> exec_loop() function is called. Is there a way of doing the loop myself
>> and calling some qt function at each iteration?
>
> What about the technique used in the semaphore.py example? Define a
> QCustomEvent that describes the GUI changes the XML-RPC thread wants and
> call
> QApplication.postEvent() - which is thread safe. Your main GUI thread
> processes the event and updates the GUI as required.
>
> Phil
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>


Albert Cervera Areny
Dept. Informàtica Sedifa, S.L.

Av. Can Bordoll, 149
08202 - Sabadell (Barcelona)
Tel. 93 715 51 11




More information about the PyQt mailing list