]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/Sound.py
apparently the check for too small rect is needed not only with wxNB_MULTILINE (see...
[wxWidgets.git] / wxPython / demo / Sound.py
index 871fdde0682f602dc617c497f347c3dfe6189d9e..2584de414c0676163fc2027f728a8019959d3533 100644 (file)
@@ -22,9 +22,9 @@ class TestPanel(wx.Panel):
 
     def OnButton1(self, evt):
         try:
-            self.sound = wx.Sound(opj('data/anykey.wav'))
+            sound = wx.Sound(opj('data/anykey.wav'))
             self.log.write("before Play...\n")
-            self.sound.Play(wx.SOUND_SYNC)
+            sound.Play(wx.SOUND_SYNC)
             self.log.write("...after Play\n")
         except NotImplementedError, v:
             wx.MessageBox(str(v), "Exception Message")
@@ -33,14 +33,15 @@ class TestPanel(wx.Panel):
     def OnButton2(self, evt):
         try:
             if True:
-                self.sound = wx.Sound(opj('data/plan.wav'))
+                sound = wx.Sound(opj('data/plan.wav'))
             else:
                 # sounds can also be loaded from a buffer object
                 data = open(opj('data/plan.wav'), 'rb').read()
-                self.sound = wx.SoundFromData(data)
+                sound = wx.SoundFromData(data)
                 
             self.log.write("before Play...\n")
-            self.sound.Play(wx.SOUND_ASYNC)
+            sound.Play(wx.SOUND_ASYNC)
+            self.sound = sound  # save a reference (This shoudln't be needed, but there seems to be a bug...)
             wx.YieldIfNeeded()
             self.log.write("...after Play\n")
         except NotImplementedError, v:
@@ -54,9 +55,12 @@ class TestPanel(wx.Panel):
                             style=wx.OPEN)
         if dlg.ShowModal() == wx.ID_OK:
             try:
-                #self.sound = wx.Sound(dlg.GetPath())
-                #self.sound.Play()
-                wx.Sound.PlaySound(dlg.GetPath())
+                #sound = wx.Sound(dlg.GetPath(), wx.SOUND_SYNC)
+                #sound.Play()
+
+                # another way to do it.
+                wx.Sound.PlaySound(dlg.GetPath(), wx.SOUND_SYNC)
+                
             except NotImplementedError, v:
                 wx.MessageBox(str(v), "Exception Message")
         dlg.Destroy()