• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10/pyobjc-45/2.6/pyobjc/pyobjc-framework-Cocoa/Examples/Twisted/WebServicesTool-CocoaBindings/
1"""
2WSTApplicationDelegateClass
3"""
4
5from AppKit import *
6
7from PyObjCTools import AppHelper
8from WSTConnectionWindowControllerClass import WSTConnectionWindowController
9
10from twisted.internet import reactor
11
12class WSTApplicationDelegate (NSObject):
13
14    @objc.IBAction
15    def newConnectionAction_(self, sender):
16        """Action method fired when the user selects the 'new connection'
17        menu item.  Note that the WSTConnectionWindowControllerClass is
18        defined the first time this method is invoked.
19
20        This kind of lazy evaluation is generally recommended;  it speeds
21        app launch time and it ensures that cycles aren't wasted loading
22        functionality that will never be used.
23
24        (In this case, it is largely moot due to the implementation of
25        applicationDidFinishLaunching_().
26        """
27        WSTConnectionWindowController.connectionWindowController().showWindow_(sender)
28
29    def applicationShouldTerminate_(self, sender):
30        if reactor.running:
31            reactor.addSystemEventTrigger(
32                'after', 'shutdown', AppHelper.stopEventLoop)
33            reactor.stop()
34            return False
35        return True
36
37    def applicationDidFinishLaunching_(self, aNotification):
38        """Create and display a new connection window
39        """
40        reactor.interleave(AppHelper.callAfter)
41        self.newConnectionAction_(None)
42