def executeVanillaTest(cls, nibPath=None, calls=None, **kwargs): """ Execute a Vanilla UI class in a mini application. """ app = _VanillaMiniApp.sharedApplication() delegate = _VanillaMiniAppDelegate.alloc().init() app.setDelegate_(delegate) if nibPath: NSBundle.loadNibFile_externalNameTable_withZone_(nibPath, {}, None) else: mainMenu = NSMenu.alloc().initWithTitle_("Vanilla Test") fileMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( "File", None, "") fileMenu = NSMenu.alloc().initWithTitle_("File") fileMenuItem.setSubmenu_(fileMenu) mainMenu.addItem_(fileMenuItem) editMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( "Edit", None, "") editMenu = NSMenu.alloc().initWithTitle_("Edit") editMenuItem.setSubmenu_(editMenu) mainMenu.addItem_(editMenuItem) helpMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( "Help", None, "") helpMenu = NSMenu.alloc().initWithTitle_("Help") helpMenuItem.setSubmenu_(helpMenu) mainMenu.addItem_(helpMenuItem) app.setMainMenu_(mainMenu) if cls is not None: cls(**kwargs) if calls is not None: for call, kwargs in calls: call(**kwargs) app.activateIgnoringOtherApps_(True) if hasCorefoundationasyncio: loop = CoreFoundationEventLoop() asyncio.set_event_loop(loop) try: loop.run_forever() finally: loop.close() else: AppHelper.runEventLoop()
def executeVanillaTest(cls, nibPath=None, calls=None, **kwargs): """ Execute a Vanilla UI class in a mini application. """ app = NSApplication.sharedApplication() delegate = _VanillaMiniAppDelegate.alloc().init() app.setDelegate_(delegate) if nibPath: NSBundle.loadNibFile_externalNameTable_withZone_(nibPath, {}, None) else: mainMenu = NSMenu.alloc().initWithTitle_("Vanilla Test") fileMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("File", None, "") fileMenu = NSMenu.alloc().initWithTitle_("File") fileMenuItem.setSubmenu_(fileMenu) mainMenu.addItem_(fileMenuItem) editMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Edit", None, "") editMenu = NSMenu.alloc().initWithTitle_("Edit") editMenuItem.setSubmenu_(editMenu) mainMenu.addItem_(editMenuItem) helpMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Help", None, "") helpMenu = NSMenu.alloc().initWithTitle_("Help") helpMenuItem.setSubmenu_(helpMenu) mainMenu.addItem_(helpMenuItem) app.setMainMenu_(mainMenu) if cls is not None: cls(**kwargs) if calls is not None: for call, kwargs in calls: call(**kwargs) app.activateIgnoringOtherApps_(True) AppHelper.runEventLoop()
# BuroFont Editor # (c) 2014+ Font Bureau # # No distribution without permission. # # ----------------------------------------------------------------------------- # # run.py # import os from PyObjCTools import AppHelper from AppKit import NSApplication, NSApp, NSBundle, NSLog # @UnresolvedImport import objc objc.setVerbose(True) # @UndefinedVariable import AppDelegate import MyWindowController app = NSApplication.sharedApplication() nibPath = os.path.join(os.path.dirname(__file__), "dist", "Skeleton.app", "Contents", "Resources", "English.lproj", "MainMenu.nib") NSBundle.loadNibFile_externalNameTable_withZone_(nibPath, {}, None) # @UndefinedVariable nibPath = os.path.join(os.path.dirname(__file__), "dist", "Skeleton.app", "Contents", "Resources", "English.lproj", "TestWindow.nib") NSBundle.loadNibFile_externalNameTable_withZone_(nibPath, {}, None) # @UndefinedVariable delegate = AppDelegate.AppDelegate.alloc().init() # @UndefinedVariable app.setDelegate_(delegate) # Bring app to top NSApp.activateIgnoringOtherApps_(True) AppHelper.runEventLoop()
# http://twistedmatrix.com/documents/13.0.0/api/twisted.internet._threadedselect.html # # import os from PyObjCTools import AppHelper from AppKit import NSApplication, NSApp, NSBundle, NSLog # @UnresolvedImport import objc objc.setVerbose(True) # @UndefinedVariable # Specialized reactor for integrating with arbitrary foreign event loop, such as those you find in GUI toolkits. from twisted.internet._threadedselect import install reactor = install() # import modules containing classes required to start application and load MainMenu.nib import XierpaAppDelegate app = NSApplication.sharedApplication() nibPath = os.path.join( os.path.dirname(__file__), "dist", "Xierpa3.app", "Contents", "Resources", "en.lproj", "MainMenu.nib" ) NSBundle.loadNibFile_externalNameTable_withZone_(nibPath, {}, None) # @UndefinedVariable delegate = XierpaAppDelegate.XierpaAppDelegate.alloc().init() # @UndefinedVariable app.setDelegate_(delegate) # Bring app to top NSApp.activateIgnoringOtherApps_(True) AppHelper.runEventLoop()