X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/65cf3a4b6a3f70a40db688f75e27d8e7457618d3..78862f240c167007c922e5fc6105e4d9522f332f:/wxPython/demo/Sound.py diff --git a/wxPython/demo/Sound.py b/wxPython/demo/Sound.py new file mode 100644 index 0000000000..fde55f785c --- /dev/null +++ b/wxPython/demo/Sound.py @@ -0,0 +1,59 @@ + +import wx + +from Main import opj + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent, -1) + + b = wx.Button(self, -1, "Play Sound 1", (25, 25)) + self.Bind(wx.EVT_BUTTON, self.OnButton1, b) + + b = wx.Button(self, -1, "Play Sound 2", (25, 65)) + self.Bind(wx.EVT_BUTTON, self.OnButton2, b) + + + def OnButton1(self, evt): + try: + sound = wx.Sound(opj('data/anykey.wav')) + sound.Play() + except NotImplementedError, v: + wx.MessageBox(str(v), "Exception Message") + + + def OnButton2(self, evt): + try: + sound = wx.Sound(opj('data/plan.wav')) + sound.Play() + except NotImplementedError, v: + wx.MessageBox(str(v), "Exception Message") + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb) + return win + +#---------------------------------------------------------------------- + + +overview = """
++This demo offers two examples, both driven by buttons, but obviously the event +that drives the playing of the sound can come from anywhere. + + +""" + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])])