1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#!/usr/bin/python
"""
__version__ = "$Revision: 1.14 $"
__date__ = "$Date: 2004/08/12 19:19:01 $"
"""
from PythonCard import dialog, model, sound
import os.path
class Sounds(model.Background) :
def on_btnPlay_mouseClick(self, event):
filename = self.components.fldFilename.text
async = self.components.chkAsync.checked
loop = self.components.chkLoop.checked
# I don't know how to stop a looped sound playing!
try:
snd = sound.Sound(filename)
snd.play(async, loop)
except:
base = os.path.basename(filename)
dialog.alertDialog(self, 'The sound file "%s" is not in a format I can understand.' % base, 'Unknown File Type')
def on_btnFile_mouseClick(self, event):
# wildcard = "JPG files (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF files (*.gif)|*.gif|All Files (*.*)|*.*"
wildcard = "Wave files (*.wav)|*.wav;*.WAV"
path = ''
filename = ''
result = dialog.openFileDialog(wildcard=wildcard)
if result.accepted:
s = result.paths[0]
self.components.fldFilename.text = s
if __name__ == '__main__':
app = model.Application(Sounds)
app.MainLoop()
|