[Twisted-Python] wxpython + twisted: how to call method on app start up

Ruslan Spivak alienoid at is.lg.ua
Tue Aug 19 03:49:19 EDT 2003


Can you help me with the following:

I have wxpython + twisted application, i have button event handler - 
when button is pressed client connects to twisted server via ssl.

class MyFrame(wxFrame, TaskBarApp):

     def OnConnect(self, event=None):
         # Called when 'connect' button is pressed
         bf = pb.PBClientFactory()
         from twisted.internet import ssl
         contextFactory = ssl.ClientContextFactory()
         reactor.connectSSL("localhost", 33333, bf, contextFactory, 30)
         d = bf.getRootObject()

         d.addCallbacks(self.gotObject, self.gotError)

class MyApp(wxApp):
     def OnInit(self):
         frame = MyFrame(NULL, -1, "Infoservice HomeLAN")
         return true

app = MyApp(0)

In my case user has option - 'autoconnect', so when application is 
launched and autoconnect is true, it will automatically connect to 
server. So i need to call OnConnect, but where is the right place where 
i need to put call to OnConnect? Should i do it with reactor callLater 
or somehow else?

Your help is very, very appreciated.
Thanks in advance.

Best regards,

More information about the Twisted-Python mailing list