def disable_focus_workaround(): global dialog global glib_id app_window.show() NSApp().setActivationPolicy_(NSApplicationActivationPolicyRegular) NSApp().activateIgnoringOtherApps_(True) GLib.idle_remove_by_data(glib_id)
def on_window_state_event(self, window, event): # FIXME: We don't receive notification on fullscreen on OSX # We'll have to figure this out some other way.. window = NSApp().mainWindow() if window is not None: window.disableSnapshotRestoration() if not self.app_ready: self.osx_menu_setup() NSApp().setActivationPolicy_(NSApplicationActivationPolicyRegular) NSApp().activateIgnoringOtherApps_(True) #force_focus(self) self.app_ready = True
def main(): app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) win = NSWindow.alloc() frame = ((200.0, 300.0), (250.0, 100.0)) win.initWithContentRect_styleMask_backing_defer_(frame, 15, 2, 0) win.setTitle_("HelloWorld") app.run()
def main(): app = NSApplication.sharedApplication() # we must keep a reference to the delegate object ourselves, # NSApp.setDelegate_() doesn't retain it. A local variable is # enough here. delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) win = NSWindow.alloc() frame = ((200.0, 300.0), (250.0, 100.0)) win.initWithContentRect_styleMask_backing_defer_(frame, 15, 2, 0) win.setTitle_("HelloWorld") win.setLevel_(3) # floating window hel = NSButton.alloc().initWithFrame_(((10.0, 10.0), (80.0, 80.0))) win.contentView().addSubview_(hel) hel.setBezelStyle_(4) hel.setTitle_("Hello!") hel.setTarget_(app.delegate()) hel.setAction_("sayHello:") beep = NSSound.alloc() beep.initWithContentsOfFile_byReference_( "/System/Library/Sounds/Tink.Aiff", 1) hel.setSound_(beep) bye = NSButton.alloc().initWithFrame_(((100.0, 10.0), (80.0, 80.0))) win.contentView().addSubview_(bye) bye.setBezelStyle_(4) bye.setTarget_(app) bye.setAction_("stop:") bye.setEnabled_(1) bye.setTitle_("Goodbye!") adios = NSSound.alloc() adios.initWithContentsOfFile_byReference_( "/System/Library/Sounds/Basso.aiff", 1) bye.setSound_(adios) win.display() win.orderFrontRegardless() # but this one does AppHelper.runEventLoop()
def invalidate_state(): NSApp().invalidateRestorableState()
def enable_focus_workaround(window): global dialog global app_window app_window.hide() NSApp().activateIgnoringOtherApps_(False) NSApp().setActivationPolicy_(NSApplicationActivationPolicyAccessory)
def windowWillClose_(self, sender): if sender is self.mainWindow: NSApp().terminate()
def main(): app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) print 'loading' AppHelper.runEventLoop()