comparison frontends/src/wix/profile.py @ 223:86d249b6d9b7

Files reorganisation
author Goffi <goffi@goffi.org>
date Wed, 29 Dec 2010 01:06:29 +0100
parents frontends/wix/profile.py@8f2ed279784b
children fd9b7834d98a
comparison
equal deleted inserted replaced
222:3198bfd66daa 223:86d249b6d9b7
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 """
5 wix: a SAT frontend
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """
21
22 import wx
23 import pdb
24 from logging import debug, info, error
25 from tools.jid import JID
26
27
28 class Profile(wx.Frame):
29 """This class is used to show/modify profile given by SàT"""
30
31 def __init__(self, host, data, title="Profile"):
32 super(Profile, self).__init__(None, title=title)
33 self.host = host
34
35 self.name_dict = { 'fullname': _('Full Name'),
36 'nick' : _('Nickname'),
37 'birthday' : _('Birthday'),
38 'phone' : _('Phone #'),
39 'website' : _('Website'),
40 'email' : _('E-mail'),
41 'avatar' : _('Avatar')
42 }
43 self.ctl_list = {} # usefull to access ctrl, key = (name)
44
45 self.sizer = wx.BoxSizer(wx.VERTICAL)
46 self.notebook=wx.Notebook(self, -1)
47 self.sizer.Add(self.notebook, 1, flag=wx.EXPAND)
48 self.SetSizer(self.sizer)
49 self.SetAutoLayout(True)
50
51 #events
52 self.Bind(wx.EVT_CLOSE, self.onClose, self)
53
54 self.MakeModal()
55 self.showData(data)
56 self.Show()
57
58 def showData(self, data):
59 flags = wx.TE_READONLY
60
61 #General tab
62 generaltab = wx.Panel(self.notebook)
63 sizer = wx.FlexGridSizer(cols=2)
64 sizer.AddGrowableCol(1)
65 generaltab.SetSizer(sizer)
66 generaltab.SetAutoLayout(True)
67 for field in ['fullname','nick', 'birthday', 'phone', 'website', 'email']:
68 value = data[field] if data.has_key(field) else ''
69 label=wx.StaticText(generaltab, -1, self.name_dict[field]+": ")
70 sizer.Add(label)
71 self.ctl_list[field] = wx.TextCtrl(generaltab, -1, value, style = flags)
72 sizer.Add(self.ctl_list[field], 1, flag = wx.EXPAND)
73 #Avatar
74 if data.has_key('avatar'):
75 filename = self.host.bridge.getAvatarFile(data['avatar'])
76 label=wx.StaticText(generaltab, -1, self.name_dict['avatar']+": ")
77 sizer.Add(label)
78 img = wx.Image(filename).ConvertToBitmap()
79 self.ctl_list['avatar'] = wx.StaticBitmap(generaltab, -1, img)
80 sizer.Add(self.ctl_list['avatar'], 0)
81
82
83
84 self.notebook.AddPage(generaltab, _("General"))
85
86
87 def onClose(self, event):
88 """Close event"""
89 debug(_("close"))
90 self.MakeModal(False)
91 event.Skip()
92