1""" 2Check if NSModalSessions are properly wrapped. 3 4XXX: This is not a proper unittest, it requires human eyes to check if the 5output is correct. 6""" 7import objc 8from Foundation import * 9from AppKit import * 10import time 11 12def doTest(): 13 alertPanel = None 14 modalSession = None 15 app = NSApplication.sharedApplication() 16 try: 17 alertPanel = NSGetInformationalAlertPanel( 18 "Please wait", "Bla bla bla", None, None, None) 19 modalSession = app.beginModalSessionForWindow_(alertPanel) 20 21 print modalSession, modalSession.pointer 22 time.sleep(1) 23 finally: 24 if modalSession is not None: 25 app.endModalSession_(modalSession) 26 modalSession = None 27 28 if alertPanel is not None: 29 NSReleaseAlertPanel(alertPanel) 30 alertPanel = None 31 32 33 34class AppDelegate (NSObject): 35 def applicationDidFinishLaunching_(self, aNotification): 36 doTest() 37 aNotification.object().terminate_(None) 38 39def main(): 40 app = NSApplication.sharedApplication() 41 42 delegate = AppDelegate.alloc().init() 43 NSApp().setDelegate_(delegate) 44 45 win = NSWindow.alloc() 46 frame = ((200.0, 300.0), (250.0, 100.0)) 47 win.initWithContentRect_styleMask_backing_defer_ (frame, 15, 2, 0) 48 win.setTitle_ ('HelloWorld') 49 50 app.run() 51 52if __name__ == '__main__' : 53 main() 54