[Tkinter-discuss] tkSnack record for specific period of time
Michael Lange
klappnase at web.de
Tue Jan 19 21:03:56 CET 2010
Hi,
On Mon, 18 Jan 2010 15:57:06 -0800 (PST)
skizm <shawn.meier at gmail.com> wrote:
>
> I am currently trying to write a code snippet that will record for a
> set period of time and I have tried a number of methods to do this
> yet none have worked, the first one I tried is listed below.
>
> from Tkinter import *
> import time
> root = Tk()
>
> import tkSnack
> tkSnack.initializeSnack(root)
> c = tkSnack.Sound()
> c.record()
> time.sleep(5) #record for 5 seconds
> c.stop()
>
> This produces an apparently empty sound file, I assume that what is
> going on here is that the sleep command pauses the entire program
> including what I am trying to record. I am sure that there is some
> proper way to do this but after searching for quite a while I am at a
> loss as to what it may be. In addition to the sleep I have tried
> the .after(...) member function of the master object. I have tried
> this with a record and stop button and it works fine.
with this slightly modified example I get the expected 5 second sound
file; doesn't this work for you ?
from Tkinter import *
import tkSnack
root = Tk()
tkSnack.initializeSnack(root)
c = tkSnack.Sound(file='test.wav')
c.record()
root.after(5000, c.stop)
root.mainloop()
Michael
More information about the Tkinter-discuss
mailing list