예제 #1
0
def application(argv=[]):
    if len(argv) > 1:
        app = NSApplication.sharedApplication()
        terminating(app, argv[1])
    else:
        app = send_message('NSApplication', 'sharedApplication')
    create_autorelease_pool()
    create_window()
    return app
예제 #2
0
def create_window():
    window = send_message('NSWindow', 'alloc')
    window = send_message(window, 'initWithContentRect:styleMask:backing:defer:',
                          NSMakeRect(10, 500, 600, 300),  # frame
                          NSWindowStyleMaskUsual,
                          NSBackingStoreBuffered,
                          0)  # or False
    send_message(window, 'setTitle:', NSStr("Window - Select Quit from Dock menu"))
    send_message(window, 'makeKeyAndOrderFront:', None)
    return window
예제 #3
0
 def _terminating():
     try:
         sleep(float(sys.argv[1]) + 0.5)
     except ValueError:
         return
     send_message(app, 'terminate:')
예제 #4
0
def application():
    app = send_message('NSApplication', 'sharedApplication')
    create_autorelease_pool()
    create_window()
    return app
예제 #5
0
def create_autorelease_pool():
    pool = send_message('NSAutoreleasePool', 'alloc')
    pool = send_message(pool, 'init')
    return pool
예제 #6
0

def application():
    app = send_message('NSApplication', 'sharedApplication')
    create_autorelease_pool()
    create_window()
    return app


if __name__ == '__main__':

    import sys

    app = application()

    if len(sys.argv) > 1:
        from threading import Thread
        from time import sleep

        def _terminating():
            try:
                sleep(float(sys.argv[1]) + 0.5)
            except ValueError:
                return
            send_message(app, 'terminate:')

        t = Thread(target=_terminating)
        t.start()

    send_message(app, 'run')  # never returns