All pastes #145042 Raw Edit

Something

public text v1 · immutable
#145042 ·published 2006-08-22 20:12 UTC
rendered paste body
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.internet import reactor, tksupport
from gui import *
from globe import *

class client(Protocol):
    def connectionMade(self):
        globe.window.text('Connected to server!')
        print 'Connected to server!'
        self.name=raw_input('Input your name: ')
        reactor.callInThread(self.write)
    def connectionLost(self,reason):
        print 'Lost connection to server!'
    def dataReceived(self,data):
        print 'Echo> %s'%data
    def dataSend(self,data):
        self.transport.write(data)
    def write(self):
        while 1:
            data=raw_input('> ')
            query='nick=%s&text=%s'%(self.name,data)
            self.dataSend(query)

class client_factory(ClientFactory):
    def startedConnecting(self,connector):
        print 'Connecting to server...'
    def clientConnectionFailed(self,connector,reason):
        print 'Could not connect to server!'
    def buildProtocol(self,addr):
        self.client=client()
        return self.client

globe.window=window()
globe.window.master.protocol('WM_DELETE_WINDOW',reactor.stop)

client_factory=client_factory()
reactor.connectTCP('70.29.210.113',8000,client_factory)
tksupport.install(globe.window.master)
reactor.run()


#################

from Tkinter import *

class window:
    def __init__(self):
        master=Tk()
        frame=Frame(master,width=100,height=100)
        frame.pack()
        text=Text(frame)
        text.pack()
        text['state']=DISABLED
        entry=Entry(frame,width=80)
        entry.pack()
        entry.bind("<Return>",self.enter)
        self.master=master
        self.frame=frame
        self.entry=entry
        self.text=text
    def run(self):
        self.master.mainloop()
    def enter(self,event):
        return 0
    def text(self,txt):
        print 'texted!'
        self.text.insert(END,txt)


#################


class globe:
    def __init__(self):
        return True