twisted and tkinter chat client

Discussion in 'Python' started by Chris, Apr 27, 2006.

  1. Chris

    Chris Guest

    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()
     
    Chris, Apr 27, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    2,237
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    470
    Jean-Paul Calderone
    Jun 17, 2008
  3. Glyph
    Replies:
    0
    Views:
    200
    Glyph
    Dec 27, 2012
  4. Glyph
    Replies:
    0
    Views:
    171
    Glyph
    Apr 3, 2013
  5. Glyph
    Replies:
    0
    Views:
    73
    Glyph
    May 12, 2014
Loading...

Share This Page