]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/Wave.py
new DC API fix
[wxWidgets.git] / wxPython / demo / Wave.py
... / ...
CommitLineData
1
2import wx
3
4from Main import opj
5
6#----------------------------------------------------------------------
7
8class TestPanel(wx.Panel):
9 def __init__(self, parent):
10 wx.Panel.__init__(self, parent, -1)
11
12 b = wx.Button(self, -1, "Play Sound 1", (25, 25))
13 self.Bind(wx.EVT_BUTTON, self.OnButton1, b)
14
15 b = wx.Button(self, -1, "Play Sound 2", (25, 65))
16 self.Bind(wx.EVT_BUTTON, self.OnButton2, b)
17
18
19 def OnButton1(self, evt):
20 try:
21 wave = wx.Wave(opj('data/anykey.wav'))
22 wave.Play()
23 except NotImplementedError, v:
24 wx.MessageBox(str(v), "Exception Message")
25
26
27 def OnButton2(self, evt):
28 try:
29 wave = wx.Wave(opj('data/plan.wav'))
30 wave.Play()
31 except NotImplementedError, v:
32 wx.MessageBox(str(v), "Exception Message")
33
34#----------------------------------------------------------------------
35
36def runTest(frame, nb, log):
37 win = TestPanel(nb)
38 return win
39
40#----------------------------------------------------------------------
41
42
43overview = """\
44This class represents a short wave file, in Windows WAV format, that can
45be stored in memory and played. Currently this class is implemented on Windows
46and GTK (Linux) only.
47
48This demo offers two examples, both driven by buttons, but obviously the event
49that drives the playing of the sound can come from anywhere.
50
51"""
52
53
54if __name__ == '__main__':
55 import sys,os
56 import run
57 run.main(['', os.path.basename(sys.argv[0])])