comparison frontends/src/wix/chat.py @ 812:084b52afdceb

frontends: fixed /me usage + renamed a couple of "type" parameters to type_
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:51:16 +0100
parents 1fe00f0c9a91
children cd02f5ef30df
comparison
equal deleted inserted replaced
811:1fe00f0c9a91 812:084b52afdceb
36 idTAROT = 2 36 idTAROT = 2
37 37
38 class Chat(wx.Frame, QuickChat): 38 class Chat(wx.Frame, QuickChat):
39 """The chat Window for one to one conversations""" 39 """The chat Window for one to one conversations"""
40 40
41 def __init__(self, target, host, type='one2one'): 41 def __init__(self, target, host, type_='one2one'):
42 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200)) 42 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200))
43 QuickChat.__init__(self, target, host, type) 43 QuickChat.__init__(self, target, host, type_)
44 44
45 self.sizer = wx.BoxSizer(wx.VERTICAL) 45 self.sizer = wx.BoxSizer(wx.VERTICAL)
46 self.SetSizer(self.sizer) 46 self.SetSizer(self.sizer)
47 47
48 self.splitter = wx.SplitterWindow(self, -1) 48 self.splitter = wx.SplitterWindow(self, -1)
78 78
79 def __createPresents(self): 79 def __createPresents(self):
80 """Create a list of present people in a group chat""" 80 """Create a list of present people in a group chat"""
81 self.present_panel = wx.Panel(self.splitter) 81 self.present_panel = wx.Panel(self.splitter)
82 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL) 82 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL)
83 self.present_panel.presents = ContactList(self.present_panel, self.host, type='nicks') 83 self.present_panel.presents = ContactList(self.present_panel, self.host, type_='nicks')
84 self.present_panel.presents.SetMinSize(wx.Size(80,20)) 84 self.present_panel.presents.SetMinSize(wx.Size(80,20))
85 self.present_panel.sizer.Add(self.present_panel.presents, 1, wx.EXPAND) 85 self.present_panel.sizer.Add(self.present_panel.presents, 1, wx.EXPAND)
86 self.present_panel.SetSizer(self.present_panel.sizer) 86 self.present_panel.SetSizer(self.present_panel.sizer)
87 self.splitter.SplitVertically(self.present_panel, self.conv_panel, 80) 87 self.splitter.SplitVertically(self.present_panel, self.conv_panel, 80)
88 88
89 def setType(self, type): 89 def setType(self, type_):
90 QuickChat.setType(self, type) 90 QuickChat.setType(self, type_)
91 if type is 'group' and not self.splitter.IsSplit(): 91 if type_ is 'group' and not self.splitter.IsSplit():
92 self.__createPresents() 92 self.__createPresents()
93 self.subjectBox.Show() 93 self.subjectBox.Show()
94 self.__eraseMenus() 94 self.__eraseMenus()
95 self.__createMenus_group() 95 self.__createMenus_group()
96 self.sizer.Layout() 96 self.sizer.Layout()
97 elif type is 'one2one' and self.splitter.IsSplit(): 97 elif type_ is 'one2one' and self.splitter.IsSplit():
98 self.splitter.Unsplit(self.present_panel) 98 self.splitter.Unsplit(self.present_panel)
99 del self.present_panel 99 del self.present_panel
100 self.GetMenuBar().Show() 100 self.GetMenuBar().Show()
101 self.subjectBox.Hide() 101 self.subjectBox.Hide()
102 self.__eraseMenus() 102 self.__eraseMenus()
234 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) 234 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic))
235 self.chatWindow.AppendText("%s\n" % msg) 235 self.chatWindow.AppendText("%s\n" % msg)
236 if not mymess: 236 if not mymess:
237 self.__blink() 237 self.__blink()
238 238
239 def printInfo(self, msg, type='normal'): 239 def printInfo(self, msg, type_='normal'):
240 """Print general info 240 """Print general info
241 @param msg: message to print 241 @param msg: message to print
242 @type: one of: 242 @type_: one of:
243 normal: general info like "toto has joined the room" 243 normal: general info like "toto has joined the room"
244 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" 244 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
245 """ 245 """
246 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) 246 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD)
247 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) 247 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL)
248 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type == 'normal' else _font_normal)) 248 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type_ == 'normal' else _font_normal))
249 self.chatWindow.AppendText("%s\n" % msg) 249 self.chatWindow.AppendText("%s\n" % msg)
250 if type=="me": 250 if type_=="me":
251 self.__blink() 251 self.__blink()
252 252
253 ### events ### 253 ### events ###
254 254
255 def onSendFile(self, e): 255 def onSendFile(self, e):