Threaded GUI slowing method execution?

Aaron Hoover ahoover at eecs.berkeley.edu
Sun Oct 4 02:03:17 EDT 2009


On Oct 2, 2009, at 1:18 PM, sturlamolden wrote:

> On 2 Okt, 21:30, Dave Angel <da... at ieee.org> wrote:
>
>> There could very well be multiprocess support in wxPython.  I'd check
>> there first, before re-inventing the wheel.
>
> I don't think there is. But one can easily make a thread in the
> subprocess that polls a pipe and calls wx.PostEvent or wx.CallLater
> when something is received. I particularly like the Queue object in
> multiprocessing for this.
>
> One could also use win32api.SendMessage from pywin32 to send the event
> from one process to another. The parent must know the hwnd of the
> subprocess main wx.Frame. The subprocess gets that from calling the
> GetHandle() method of its wx.Frame, and must post it back to the
> parent, presumably via a pipe.
>
>

So, I managed to solve all of this ultimately by simply creating a new  
process for managing the serial connection with a TX and RX queue.  
Then, in the GUI, I created a thread that's responsible for reading  
from the RX queue and posting the appropriate events based on the data  
it pulls off of the queue.

It's plenty fast for 2KHz sampling rates, so I'm happy with it for  
now. But, I'm also grateful for all the suggestions for different  
approaches to the problem - they've really opened to what's possible  
with Python and the various libraries that enable interfacing with  
"lower" level languages like C.





More information about the Python-list mailing list