[wxPython-users] Handling 'stop' button on pyaudio recording

Robin Dunn robin at alldunn.com
Thu Feb 15 09:22:48 PST 2007


Tom Taylor wrote:
> Hi,
> 
> I'm trying to work out how to handle a 'stop' button for a PyAudio 
> (PortAudio library) recording I'm doing from within my application.
> 
> At the moment the recording simply times out after a specific number of 
> loops (equivalent to 30s) , but I want it to be able to use a stop 
> button instead. However, whilst recording the GUI is locked, because 
> it's in a loop appending audio stream data to an array.
> 
> How is it best to handle this interaction? Should I be exploring 
> threading/forking?

Yes.  In order to keep the UI responsive you don't want to do anything 
in an event handler that blocks, or in other words, anything that 
prevents the event handler from returning immediately to the MainLoop. 
If it is blocked then there can be no more events delivered during that 
time.  If you have to do something that takes a relatively long time to 
accomplish then you either want to do it in another thread, or find a 
way to slice it up into multiple small pieces.  See 
http://wiki.wxpython.org/index.cgi/LongRunningTasks for more info.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list