Example #1
0
class TKLilaDisplay(tk.Toplevel):
    '''
    One of these is created for every conversation.
    '''
    def __init__(self, protocol, host, contact):
        tk.Toplevel.__init__(self)
        self.title('%s@%s|%s' % (protocol.user, host, contact))
        self.protocol('WM_DELETE_WINDOW', self.leave_conversation)
        
        self.disp = SConsole(self, height=15, wrap=WORD)
        self.disp.pack(side=TOP)
        
        tk.Button(self, text='Send', command=self.send_msg).pack(
                side=TOP, expand=True, fill=X)
        
        self.text = STextPlus(self, height=5, wrap=WORD)
        self.text.pack(side=TOP)
        
        self.contact = contact
        self.proto = protocol
        
        self.join_conversation()
    
    def send_msg(self):
        msg = self.text.gettext().strip()
        if not msg:
            return
        self.proto.say(self.contact, msg)
        self.text.clear()
    
    def join_conversation(self):
        self.proto.join_conversation(self)
    def leave_conversation(self):
        self.proto.leave_conversation(self)
        self.destroy()
Example #2
0
 def __init__(self, protocol, host, contact):
     tk.Toplevel.__init__(self)
     self.title('%s@%s|%s' % (protocol.user, host, contact))
     self.protocol('WM_DELETE_WINDOW', self.leave_conversation)
     
     self.disp = SConsole(self, height=15, wrap=WORD)
     self.disp.pack(side=TOP)
     
     tk.Button(self, text='Send', command=self.send_msg).pack(
             side=TOP, expand=True, fill=X)
     
     self.text = STextPlus(self, height=5, wrap=WORD)
     self.text.pack(side=TOP)
     
     self.contact = contact
     self.proto = protocol
     
     self.join_conversation()