File: sounds.py

package info (click to toggle)
pythoncard 0.8.1-8.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 5,352 kB
  • ctags: 4,594
  • sloc: python: 42,401; makefile: 55; sh: 22
file content (37 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download
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()