]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-18/sound.py
2 from wx
.lib
.filebrowsebutton
import FileBrowseButton
4 class MyFrame(wx
.Frame
):
6 wx
.Frame
.__init
__(self
, None, title
="wx.Sound",
11 self
.fbb
= FileBrowseButton(p
,
12 labelText
="Select WAV file:",
14 btn
= wx
.Button(p
, -1, "Play")
15 self
.Bind(wx
.EVT_BUTTON
, self
.OnPlaySound
, btn
)
17 # setup the layout with sizers
18 sizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
19 sizer
.Add(self
.fbb
, 1, wx
.ALIGN_CENTER_VERTICAL
)
20 sizer
.Add(btn
, 0, wx
.ALIGN_CENTER_VERTICAL
)
21 border
= wx
.BoxSizer(wx
.VERTICAL
)
22 border
.Add(sizer
, 0, wx
.EXPAND|wx
.ALL
, 15)
26 def OnPlaySound(self
, evt
):
27 filename
= self
.fbb
.GetValue()
28 self
.sound
= wx
.Sound(filename
)
30 self
.sound
.Play(wx
.SOUND_ASYNC
)
32 wx
.MessageBox("Invalid sound file", "Error")
35 app
= wx
.PySimpleApp()