|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hello. I'm trying to get a better grasp of Twisted and Tkinter programming by writing a simple chat program. My server is simple enough and works well, and the client mostly works except for 1 problem:
The client cannot call the basic.LineReceiver class from any other class to sendLine. It can can call any function from the basic.LineReceiever so long as the function does not sendLine. The error I receive when trying to call sendLine from chatFacory.sendMessage() is this: in sendLine return self.transport.write(line + self.delimiter) AttributeError: 'NoneType' object has no attribute 'write' The classes I am working with are as follows: class chatClient(basic.LineReceiver): def connectionMade(self): self.sendLine("A new person has entered the room!") def message(self): self.sendLine("Bah") def lineReceived(self, line): app.text_output.config(state=NORMAL) #enable text_output for insert app.text_output.insert(END, line +"\n") app.text_output.config(state=DISABLED) app.text_input.delete(0, END) #clear text_input app.text_output.see(END) #move scrollbar to the bottom def connectionLost(self, reason): from twisted.internet import reactor reactor.stop() class chatFactory(protocol.ClientFactory): protocol = chatClient def clientConnectionFailed(self, connector, reason): print "Connection failed - goodbye!" reactor.stop() def clientConnectionLost(self, connector, reason): print "Connection lost - goodbye!" reactor.stop() def sendMessage(self): c = chatClient() c.message() If anyone has run across a similar problem and can offer any advice, I would greatly appreciate it! Thanks, Captain N |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > How do I sendLine externally with a twisted.basic.LineReceiver? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|