def applicationDidFinishLaunching_(self, note): pth = self.opts['file'] if self.mode=='windowed': # load the viewer ui from the nib in plotdevice/rsrc nib = NSData.dataWithContentsOfFile_(rsrc_path('viewer.nib')) ui = NSNib.alloc().initWithNibData_bundle_(nib, None) ok, objs = ui.instantiateNibWithOwner_topLevelObjects_(self, None) NSApp().setMainMenu_(self.menu) # configure the window script-controller, and update-watcher self.script.setScript_options_(pth, self.opts) self.window.setTitleWithRepresentedFilename_(pth) # self.script.setWindowFrameAutosaveName_('plotdevice:%s'%self.opts['file']) # foreground the window (if -b wasn't passed) and run the script if opts['activate']: NSApp().activateIgnoringOtherApps_(True) self.script.showWindow_(self) AppHelper.callAfter(self.script.scriptedRun) elif self.mode=='headless': # create a window-less WindowController self.script = ConsoleScript.alloc().init() self.script.setScript_options_(pth, self.opts) # BUG? FEATURE? (it's a mystery!) # exports will stall if `last` isn't an int. this should probably # be handled by the command line arg-parser though, no? if not opts.get('last',None): opts['last'] = opts.get('first', 1) # kick off an export session format = self.opts['export'].rsplit('.',1)[1] kind = 'movie' if format in ('mov','gif') else 'image' self.script.exportInit(kind, self.opts['export'], self.opts)
def applicationDidFinishLaunching_(self, note): pth = self.opts["file"] if self.mode == "windowed": # load the viewer ui from the nib in plotdevice/rsrc nib = NSData.dataWithContentsOfFile_(rsrc_path("viewer.nib")) ui = NSNib.alloc().initWithNibData_bundle_(nib, None) ok, objs = ui.instantiateNibWithOwner_topLevelObjects_(self, None) NSApp().setMainMenu_(self.menu) # configure the window script-controller, and update-watcher self.script.setScript_options_(pth, self.opts) self.window.setTitleWithRepresentedFilename_(pth) # self.script.setWindowFrameAutosaveName_('plotdevice:%s'%self.opts['file']) # foreground the window (if -b wasn't passed) and run the script if opts["activate"]: NSApp().activateIgnoringOtherApps_(True) self.script.showWindow_(self) AppHelper.callAfter(self.script.scriptedRun) elif self.mode == "headless": # create a window-less WindowController self.script = ConsoleScript.alloc().init() self.script.setScript_options_(pth, self.opts) # BUG? FEATURE? (it's a mystery!) # exports will stall if `last` isn't an int. this should probably # be handled by the command line arg-parser though, no? if not opts.get("last", None): opts["last"] = opts.get("first", 1) # kick off an export session format = self.opts["export"].rsplit(".", 1)[1] kind = "movie" if format in ("mov", "gif") else "image" self.script.exportInit(kind, self.opts["export"], self.opts)
def sharedApplicationForMode_(cls, mode): app = cls.sharedApplication() if mode=='headless': app.setActivationPolicy_(NSApplicationActivationPolicyAccessory) elif mode=='windowed': icon = NSImage.alloc().initWithContentsOfFile_(rsrc_path('viewer.icns')) app.setApplicationIconImage_(icon) return app
def sharedApplicationForMode_(cls, mode): app = cls.sharedApplication() if mode == "headless": app.setActivationPolicy_(NSApplicationActivationPolicyAccessory) elif mode == "windowed": icon = NSImage.alloc().initWithContentsOfFile_(rsrc_path("viewer.icns")) app.setApplicationIconImage_(icon) return app