Twisted and Tkinter
Fredrik Lundh
fredrik at pythonware.com
Thu Apr 27 11:42:44 EDT 2006
Chris wrote:
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
> return self.func(*args)
> TypeError: unbound method sendMessage() must be called with ChatFactory
> instance as first argument (got nothing instead)
that's another error message, of course...
>
> 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")
>
> root = Tk()
> b1 = Button(root,text="Send")
> b1.configure(command=ChatFactory.sendMessage)
umm. what is that line supposed to do ?
if the purpose is to call the sendMessage method of the Chat-
Message instance you're passing to connectTCP, it's probably
better to create the instance first:
chat = ChatFactory()
root = Tk()
b1 = Button(root,text="Send")
b1.configure(command=chat.sendMessage)
b1.pack()
tksupport.install(root)
reactor.connectTCP('localhost',8886,chat)
reactor.run()
</F>
More information about the Python-list
mailing list