开发者

playing WAV files in python using Snack

开发者 https://www.devze.com 2023-01-29 18:40 出处:网络
So I开发者_高级运维 downloaded Snack and put the Snacklib in python/tcl and put the tkSnack.py into python/Lib but i still dont get any sound.I\'m not getting any errors but im still not getting any s

So I开发者_高级运维 downloaded Snack and put the Snacklib in python/tcl and put the tkSnack.py into python/Lib but i still dont get any sound. I'm not getting any errors but im still not getting any sound.Here's my code...

from Tkinter import *
from tkSnack import *

root = Tk()

tkSnack.initializeSnack(root)

snd = Sound() 
snd.read('ex1.wav')
snd.play()

If anyone has any advice it would be greatly appreciated.


Shouldn't you be adding the mainloop for tk?

from Tkinter import *
from tkSnack import *

root = Tk()

tkSnack.initializeSnack(root)

snd = Sound() 
snd.read('ex1.wav')   <--- Also good to give full path to file
snd.play()
root.mainloop()   <------ main loop 

See the manual, it suggests other ways of loading too.

snd = tkSnack.Sound(file='ex1.wav')
0

精彩评论

暂无评论...
验证码 换一张
取 消