File: sounds.py

package info (click to toggle)
pythoncard 0.8.2-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,452 kB
  • ctags: 5,443
  • sloc: python: 56,787; makefile: 56; sh: 22
file content (37 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download | duplicates (3)
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.15 $"
__date__ = "$Date: 2005/09/18 03:59:22 $"
"""

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 sound.SoundFileError:
            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()