470,636 Members | 1,462 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

twisted and tkinter chat client

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()

Apr 27 '06 #1
0 1592

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rico Huijbers | last post: by
3 posts views Thread by John Wright | last post: by
1 post views Thread by PeterG | last post: by
9 posts views Thread by Chris | last post: by
44 posts views Thread by bg_ie | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.