• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10.1/pyobjc-45/pyobjc/pyobjc-framework-Cocoa-2.5.1/Examples/Twisted/WebServicesTool/
1"""
2WSTApplicationDelegateClass
3
4An instance of this class is instantiated in the MainMenu.nib default NIB file.
5"""
6
7from Cocoa import *
8from PyObjCTools import AppHelper
9from twisted.internet import reactor
10
11from WSTConnectionWindowControllerClass import WSTConnectionWindowController
12
13class WSTApplicationDelegate (NSObject):
14
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_(
28            sender)
29
30    def applicationShouldTerminate_(self, sender):
31        if reactor.running:
32            reactor.stop()
33            return False
34        return True
35
36    def applicationDidFinishLaunching_(self, aNotification):
37        """Create and display a new connection window
38        """
39        reactor.interleave(AppHelper.callAfter)
40        reactor.addSystemEventTrigger(
41            'after', 'shutdown', AppHelper.stopEventLoop)
42        self.newConnectionAction_(None)
43