# -*- coding: latin-1 -*- import wx import time import locale import os LANDLINE = 1 MOBILE = 2 numbers_mobile = [] numbers_landline = [] numbers_both = [] current_list = [] current_numbers = [] app_name = "GetWired Phone Dialer" class MainWindow(wx.Frame): def __init__(self,parent,id,title): self.call_type = 1 wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800,600), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) menubar = wx.MenuBar() menu_file = wx.Menu() menu_help = wx.Menu() menu_file.Append(101, "E&xit", "Exit GetWired phone dialer.") menu_help.Append(201, "&About", "Display information about this program.") menubar.Append(menu_file, '&File') menubar.Append(menu_help, '&Help') self.SetMenuBar(menubar) self.CreateStatusBar() self.panel = wx.Panel(self, -1) self.number_entry = wx.TextCtrl(self.panel, -1, '', (150,450), (550, 50), style=wx.TE_RIGHT) self.number_entry.SetFont( wx.Font(26, wx.MODERN, wx.NORMAL, wx.BOLD) ) self.dial_button = wx.Button(self.panel, 11, 'Dial', (710,450), (70,50),5) self.dial_button.SetDefault() self.dial_button.SetFont (wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL)) keypad_label = wx.StaticText(self.panel, -1, "Dial desired phone number:", (10,195)) keypad_label.SetFont( wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) ) dial_buttons_font = wx.Font(20, wx.MODERN, wx.NORMAL, wx.BOLD) self.dial_buttons = [] x = 0 y = 1 button_size = 70 y_offset = 170 x_offset = 10 self.dial_buttons.append(wx.Button(self.panel, 10, "0", (x_offset + button_size, y_offset + button_size*4), (button_size,button_size))) self.dial_buttons[0].SetFont( dial_buttons_font ) for i in range(1,10): if i in (4,7): x = 0 y += 1 self.dial_buttons.append(wx.Button(self.panel, i, str(i), (x + x_offset, y*button_size + y_offset), (button_size,button_size))) self.dial_buttons[i].SetFont( dial_buttons_font ) x += button_size dest_type_label = wx.StaticText(self.panel, -1, "Choose mobile or landline:", (10,10) ) dest_type_label.SetFont( wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) ) radio_landline = wx.RadioButton(self.panel, 1, "Landline", (20,40), (100,20), style=wx.RB_GROUP) radio_mobile = wx.RadioButton(self.panel, 2, "Mobile", (20,70), (100,20)) radio_mobile.SetFont( wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) ) radio_landline.SetFont( wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) ) self.landline_img = wx.Bitmap('landline.bmp') self.mobile_img = wx.Bitmap('mobile.bmp') countries_label = wx.StaticText(self.panel, -1, "Choose which country you wish to call:", (10,110)) countries_label.SetFont( wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) ) self.countries_list = wx.Choice(self.panel, -1, (10,150), (300,200)) self.countries_list.SetFont( wx.Font(12, wx.NORMAL, wx.NORMAL, wx.BOLD) ) self.countries_list.SetForegroundColour('#4444CC') self.Bind(wx.EVT_BUTTON, self.OnClick) self.Bind(wx.EVT_MENU, self.OnClick) self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Centre() def OnPaint (self, event): dc = wx.PaintDC(self.panel) if self.call_type == 1: img = self.landline_img elif self.call_type == 2: img = self.mobile_img dc.DrawBitmap(img, 150, 32) wx.PaintDC(self) def OnClick (self, evt): if evt.GetId(): id = evt.GetId() if id in range(1,11): if id == 10: id = 0 self.number_entry.AppendText(str(id)) return if id == 11: dial_number() if id == 101: self.Close() if id == 201: self.ShowHelp() def OnRadio (self, evt): self.call_type = evt.GetId() self.Refresh() populate_list(self.call_type) def ShowHelp (self): message_dialog('About', 'GetWired telephone dialer.\r\nBy Bob Farrell, copyright (c) 2007.') class CallDialog(wx.Dialog): def __init__ (self, parent, id, title, prefix_num, call_rate, base_rate, country): self.phone_number = title self.country = country self.call_rate = call_rate self.base_rate = base_rate wx.Dialog.__init__(self, parent, id, title, size=(400,220), style=0) main_font = wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) now_calling = wx.StaticText(self, -1, "", (0, 20), (400,70), style=wx.ALIGN_CENTER | wx.ST_NO_AUTORESIZE) now_calling.SetLabel("Now calling (" + str(call_rate) + "p/min):") now_calling.SetFont(main_font) number_dialed = wx.StaticText(self, -1, "", (0,45), (400,70), style=wx.ALIGN_CENTER | wx.ST_NO_AUTORESIZE) number_dialed.SetFont(main_font) number_dialed.SetLabel(self.phone_number) number_dialed.SetForegroundColour(wx.BLUE) self.call_length = wx.StaticText(self, -1, "Call Duration: 00:00:00", (0,80), (400,20), style=wx.ALIGN_CENTER | wx.ST_NO_AUTORESIZE) self.call_length.SetFont(main_font) self.call_length.SetForegroundColour('sea green') self.cost = wx.StaticText(self, -1, "Call Cost: £0.00", (0,105), (400,20), style=wx.ALIGN_CENTER | wx.ST_NO_AUTORESIZE) self.cost.SetFont( main_font ) end_button = wx.Button(self, -1, "End Call", (150, 150), (100,50), style=wx.CENTER) end_button.SetFont( wx.Font(14, wx.NORMAL, wx.NORMAL, wx.BOLD) ) self.Center() self.Bind(wx.EVT_BUTTON, self.OnClick) self.StartTimer() def OnClick (self, evt): self.timer.Stop() try: if not os.path.exists('call_log.html'): f = open('call_log.html', 'w') f.write('
| Time of Call: | Country Called: | Number Called: | Call Duration: | Call Cost: |
| ' + time.strftime('%c') + ' | ' + self.country + ' | ' + self.phone_number + ' | ' + self.call_length.GetLabel().split('Call Duration:')[1] + ' | £'.encode('latin-1') + ps.encode('latin-1') + str(self.pounds) + ' |