comparison frontends/wix/gateways.py @ 29:df3b0b5ac49e

Wix: gateways manager => better presentation
author Goffi <goffi@goffi.org>
date Tue, 08 Dec 2009 02:31:35 +0100
parents c2b131e4e262
children d6b613764dd7
comparison
equal deleted inserted replaced
28:c2b131e4e262 29:df3b0b5ac49e
32 def __init__(self, host, gateways, title="Gateways manager"): 32 def __init__(self, host, gateways, title="Gateways manager"):
33 super(GatewaysManager, self).__init__(None, title=title) 33 super(GatewaysManager, self).__init__(None, title=title)
34 34
35 self.host = host 35 self.host = host
36 #self.gateways = gateways 36 #self.gateways = gateways
37
38 #Fonts
39 self.normal_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
40 self.bold_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
41 self.italic_font = wx.Font(8, wx.DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL)
42
37 43
38 self.modified = {} # dict of modified data (i.e. what we have to save) 44 self.modified = {} # dict of modified data (i.e. what we have to save)
39 self.ctl_list = {} # usefull to access ctrl, key = (name, category) 45 self.ctl_list = {} # usefull to access ctrl, key = (name, category)
40 46
41 self.sizer = wx.BoxSizer(wx.VERTICAL) 47 self.sizer = wx.BoxSizer(wx.VERTICAL)
42 self.panel = wx.Panel(self) 48 self.panel = wx.Panel(self)
43 self.panel.sizer = wx.BoxSizer(wx.VERTICAL) 49 self.panel.sizer = wx.FlexGridSizer(cols=4)
44 self.panel.SetSizer(self.panel.sizer) 50 self.panel.SetSizer(self.panel.sizer)
45 self.panel.SetAutoLayout(True) 51 self.panel.SetAutoLayout(True)
46 self.sizer.Add(self.panel, 1, flag=wx.EXPAND) 52 self.sizer.Add(self.panel, 1, flag=wx.EXPAND)
47 self.SetSizer(self.sizer) 53 self.SetSizer(self.sizer)
48 self.SetAutoLayout(True) 54 self.SetAutoLayout(True)
49 55
50 #events 56 #events
51 self.Bind(wx.EVT_CLOSE, self.onClose, self) 57 self.Bind(wx.EVT_CLOSE, self.onClose, self)
52 58
53 self.MakeModal() 59 self.MakeModal()
54 60 self.panel.sizer.Add(wx.Window(self.panel, -1))
61 title_name = wx.StaticText(self.panel, -1, "Name")
62 title_name.SetFont(self.bold_font)
63 title_type = wx.StaticText(self.panel, -1, "Type")
64 title_type.SetFont(self.bold_font)
65 self.panel.sizer.Add(title_name)
66 self.panel.sizer.Add(title_type)
67 self.panel.sizer.Add(wx.Window(self.panel, -1))
68
55 for gateway in gateways: 69 for gateway in gateways:
56 self.addGateway(gateway, gateways[gateway]) 70 self.addGateway(gateway, gateways[gateway])
57 71
58 72
59 self.panel.sizer.Fit(self) 73 self.panel.sizer.Fit(self)
60 74
61 self.Show() 75 self.Show()
62 76
63 def addGateway(self, gateway, param): 77 def addGateway(self, gateway, param):
64 sizer = wx.BoxSizer(wx.HORIZONTAL)
65 78
66 bold_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
67 italic_font = wx.Font(8, wx.DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL)
68 79
69 80
70 #First The icon 81 #First The icon
71 isz = (16,16) 82 isz = (16,16)
72 im_icon = wx.StaticBitmap(self.panel, -1, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, isz)) 83 im_icon = wx.StaticBitmap(self.panel, -1, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, isz))
73 84
85 #Then the name
86
87 label=wx.StaticText(self.panel, -1, param['name'])
88 label.SetFont(self.normal_font)
89
74 #Then the transport type message 90 #Then the transport type message
75 91
76 type_label_txt = 'Unknown IM' 92 type_label_txt = 'Unknown IM'
77 93
78 if param['type'] == 'msn': 94 if param['type'] == 'irc':
95 type_label_txt = "Internet Relay Chat"
96 elif param['type'] == 'xmpp':
97 type_label_txt = "XMPP"
98 elif param['type'] == 'qq':
99 type_label_txt = "Tencent QQ"
100 elif param['type'] == 'simple':
101 type_label_txt = "SIP/SIMPLE"
102 elif param['type'] == 'icq':
103 type_label_txt = "ICQ"
104 elif param['type'] == 'yahoo':
105 type_label_txt = "Yahoo! Messenger"
106 elif param['type'] == 'gadu-gadu':
107 type_label_txt = "Gadu-Gadu"
108 elif param['type'] == 'aim':
109 type_label_txt = "AOL Instant Messenger"
110 elif param['type'] == 'msn':
79 type_label_txt = 'Windows Live Messenger' 111 type_label_txt = 'Windows Live Messenger'
80 112
81 type_label_txt = " " + type_label_txt + " " 113 type_label_txt = type_label_txt
82 114
83 type_label = wx.StaticText(self.panel, -1, type_label_txt) 115 type_label = wx.StaticText(self.panel, -1, type_label_txt)
84 type_label.SetFont(bold_font) 116 type_label.SetFont(self.italic_font)
85 117
86 #Then the name 118 #The buttons
119 button_font = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD)
120 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8))
121 reg_button.SetFont(button_font)
87 122
88 label=wx.StaticText(self.panel, -1, '('+param['name']+')') 123 self.panel.sizer.Add(im_icon)
89 label.SetFont(italic_font) 124 self.panel.sizer.Add(label)
90 125 self.panel.sizer.Add(type_label)
91 #The buttons 126 self.panel.sizer.Add(reg_button, 1, wx.EXPAND)
92 bold_font2 = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD)
93 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8))
94 reg_button.SetFont(bold_font2)
95
96 sizer.Add(im_icon)
97 sizer.Add(type_label)
98 sizer.Add(label, 1, wx.EXPAND)
99 sizer.Add(reg_button, 1, wx.EXPAND)
100 self.panel.sizer.Add(sizer, flag=wx.EXPAND)
101 127
102 128
103 def onClose(self, event): 129 def onClose(self, event):
104 """Close event""" 130 """Close event"""
105 debug("close") 131 debug("close")