Mi codigo:
Código Python:
Ver original
import SocketServer, wx class MyTCPHandler(SocketServer.BaseRequestHandler, wx.Frame): def __init__(self): parent, id, title = None, -1, 'jespy' wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(250, 50)) self.panel_1 = wx.Panel(self, wx.ID_ANY) self.panel_1.SetMinSize((320, 220)) self.textochat = wx.TextCtrl(self, wx.ID_ANY, style = wx.TE_MULTILINE| wx.TE_READONLY) self.textochat.SetMinSize((320, 220)) toolbar = self.CreateToolBar() self.power = toolbar.AddLabelTool(wx.ID_ANY, 'Quit', wx.Bitmap('power.png')) self.refresh = toolbar.AddLabelTool(wx.ID_ANY, 'Refresh', wx.Bitmap('refresh.png')) toolbar.Realize() self.text_ctrl_1 = wx.TextCtrl(self, wx.ID_ANY, "") self.text_ctrl_1.SetMinSize((320, 40)) self.botones = wx.Button(self, wx.ID_ANY, ("Enviar")) self.panel_1.SetBackgroundColour(wx.Colour(255,255,255)) self.textochat.SetBackgroundColour(wx.Colour(255,255,255)) sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer_2 = wx.BoxSizer(wx.VERTICAL) sizer_3 = wx.BoxSizer(wx.VERTICAL) sizer_2.Add(self.textochat, 0, wx.EXPAND, 0) sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) self.SetSizer(sizer_1) sizer_1.Fit(self) def handle(self): self.data = self.request.recv(1024).strip() self.request.sendall(self.data.upper()) print self.data try: HOST, PORT = "localhost", 6063 server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) ip = server.server_address print ip class appjes(wx.App): def OnInit(self): frame = MyTCPHandler() frame.SetBackgroundColour(wx.Colour(71,159,221)) frame.Show(True) frame.Centre() return True app = appjes(0) app.MainLoop() server.serve_forever() except SocketServer.error as e: print "el cliente se desconecto"