[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnumed-devel] re: callback from event loop in wxPython
From: |
syan tan |
Subject: |
Re: [Gnumed-devel] re: callback from event loop in wxPython |
Date: |
Tue, 03 Feb 2004 09:55:49 +0800 |
> As I said, I didn't care whichever way events got INTO GnuMed
> but rather how they were transferred into the "main" event
loop.
I tried this way, and it didn't seem to slow down
anything severely. Maybe the phrasewheel might be
affected, but I think it still works on testing the
suburb popup in the demographics panel.
Diff for python-common/gmDispatcher.py
9a10
> import Queue
10a12
> queue = Queue.Queue(100)
93c95,114
< def send(signal, sender=None, **kwds):
---
>
> def send(signal, sender=None, **kwds):
> item= (signal, sender, kwds)
> try:
> queue.put_nowait(item)
> except Queue.Full:
> print "queue full"
>
> def sendQueued():
> while 1:
> try:
> (signal, sender, kwds) = queue.get_nowait()
> _send(signal, sender, **kwds)
>
> except Queue.Empty:
> return
>
>
>
> def _send(signal, sender=None, **kwds):
diff for wxpython/gmGuiMain.py
325c325
< # EVT_IDLE(self, self.OnIdle)
---
> EVT_IDLE(self, self.OnIdle)
508a509
>
520c521
< # def OnIdle(self, event):
---
> def OnIdle(self, event):
523c524,528
< # pass
---
> gmDispatcher.sendQueued()
One problem I could see here is that if OnIdle
isn't called for a long time (which it shouldn't)
no signals would be passed on , and the gmDispatcher
queue would just bloat up with signals.