944,082 Members | Top Members by Rank

Ad:
  • Python Code Snippet
  • Views: 5518
  • Python RSS
0

Tkinter Sound (Python)

by on Jun 26th, 2006
The module tkSnack from our friends at KTH in Stockholm, Sweden allows you to play a variety of sound files using the Tkinter GUI. Supported sound files are WAV, MP3, AU, SND and AIFF formats.
Python Code Snippet (Toggle Plain Text)
  1. # using tkSnack to play .wav .mp3 and .au sound files on Tkinter
  2. # needs Python module tkSnack developed at KTH in Stockholm, Sweden
  3. # free download: snack229-py.zip or later version
  4. # from: http://www.speech.kth.se/snack/
  5. # on my system I copied tkSnack.py to D:\Python24\Lib and the folder snacklib to D:\Python24\tcl
  6. # tested with Python24 vegaseat 25jun2006
  7.  
  8. from Tkinter import *
  9. import tkFileDialog
  10. import tkSnack
  11.  
  12. form1 = Tk()
  13. # have to initialize the sound system
  14. tkSnack.initializeSnack(form1)
  15.  
  16. def load_play_sound():
  17. mask_list = [("Sound files","*.wav *.au *.mp3")]
  18. sound_file = tkFileDialog.askopenfilename(initialdir='', filetypes=mask_list)
  19. form1.title('...'+sound_file[-15:])
  20. sound1 = tkSnack.Sound(load=sound_file)
  21. sound1.play()
  22.  
  23. label1 = Label(form1, text=' using tkSnack to play .wav .mp3 and .au sound files ')
  24. label1.pack(side=TOP)
  25. button1 = Button(form1, text=' Load Sound ', command=load_play_sound)
  26. button1.pack(side=TOP)
  27.  
  28. form1.mainloop()
Comments on this Code Snippet
Dec 17th, 2009
0

Re: Tkinter Sound (Python)

Does anybody knows how to use py2exe, and include tkSnack ???
I guess there is something with a 'packages' option, but I can't find any documentation.
Thank for your help
Newbie Poster
yvos91 is offline Offline
2 posts
since Dec 2009
Message:
Previous Thread in Python Forum Timeline: I need your view on this project
Next Thread in Python Forum Timeline: IDLE in snow leopard





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC