Regenerate.
[wammu.git] / Wammu / Ringtone.py
blobe60efce1d21b833b789141ca9b273a900d3315e6
1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
3 '''
4 Wammu - Phone manager
5 Ringtone displaying and playback
6 '''
7 __author__ = 'Michal Čihař'
8 __email__ = 'michal@cihar.com'
9 __license__ = '''
10 Copyright © 2003 - 2008 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 more details.
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 '''
26 import wx
27 import Wammu.Data
28 import Wammu
29 if Wammu.gammu_error == None:
30 import gammu
31 import os
32 import thread
33 import commands
35 ringtones = {}
37 class Ringtone(wx.BitmapButton):
38 def __init__(self, parent, tooltip = 'Melody', ringno = 0, size = None, scale = 1):
39 bitmap = wx.BitmapFromXPMData(Wammu.Data.Note)
40 wx.BitmapButton.__init__(self, parent, -1, bitmap, (0,0))
41 self.SetToolTipString(tooltip)
42 self.ringtone = ringtones[int(ringno)]
43 wx.EVT_BUTTON(self, self.GetId(), self.OnClick)
45 def OnClick(self, evt):
46 if commands.getstatusoutput('which timidity')[0] != 0:
47 wx.MessageDialog(self,
48 _('Could not find timidity, melody can not be played'),
49 _('Timidity not found'),
50 wx.OK | wx.ICON_ERROR).ShowModal()
51 return
52 f = os.popen('timidity -', 'w')
53 thread.start_new_thread(gammu.SaveRingtone, (f, self.ringtone, "mid"))