wxpython: breaking from a while loop when an event occurs -
i want create wxpython application buffers audio input inside infinite while loop, until chekbox clicked. tried out following code, didn't responds event , iterates in while loop. please me continue project work. in advance
while 1: #buffering of audio data if self.checkbox_1.getvalue(): #checking external event external event not working , cant check check box break
the answer threads. creating infinite loop, blocking ui's event loop. buffering piece in separate thread. in thread, need buffering in chunks (like kilobyte @ time). after each chunk, use 1 of wxpython's threadsafe methods ask wxpython if checkbox checked. thread-safe methods wx.callafter, wx.calllater , wx.postevent. recommend first or last.
the wxpython wiki explains how add threads:
i have old article on topic:
Comments
Post a Comment