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