Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > twisted and tkinter chat client

Reply
Thread Tools

twisted and tkinter chat client

 
 
Chris
Guest
Posts: n/a
 
      04-27-2006
Hi,

Sorry for reposting but I changed my code and received a new error
message so I thought I would try it on the group again. I have a
working server and this is meant to be a chat client using tkinter that
connects to the server and sends messages. However I receive this error
message when I click the send button:

Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "C:\Documents and Settings\chris\Desktop\Python\client.py", line
30, in sendMessage
self.sendLine("Test")
AttributeError: ChatFactory instance has no attribute 'sendLine'

Any help really appreciated. Thanks to anyone who has already tried.

The code is here:
from twisted.internet import reactor
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.protocols.basic import LineReceiver
from Tkinter import *
from twisted.internet import tksupport

class ChatClient(LineReceiver):

def connectionMade(self):
self.sendLine("Hello server")

def lineReceived(self, line):
print line

def connectionLost(self, reason):
pass


class ChatFactory(ClientFactory):

protocol = ChatClient

def clientConnectionFailed(self, connector, reason):
reactor.stop()

def clientConnectionLost(self, connector, reason):
reactor.stop()

def sendMessage(self):
self.sendLine("Test")

chat = ChatFactory()
root = Tk()
b1 = Button(root,text="Send")
b1.configure(command=chat.sendMessage)
b1.pack()
tksupport.install(root)

reactor.connectTCP('localhost',8885,ChatFactory())
reactor.run()

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Twisted-Python] Twisted 13.0.0 released Glyph Python 0 04-03-2013 09:36 PM
Re: [Twisted-Python] Twisted 12.3.0 released Glyph Python 0 12-27-2012 06:40 AM
Re: [Twisted-Python] Re-working a synchronous iterator to use Twisted Jean-Paul Calderone Python 0 06-17-2008 10:14 PM
Twisted and Tkinter Chris Python 9 04-28-2006 02:40 PM
Chat Server and Chat Client for INTRANET diptanu@gmail.com Java 0 01-30-2006 06:56 PM



Advertisments