def showAboutPlugin_(self, sender): icon = None info = objc.currentBundle().infoDictionary() if 'CFBundleIconFile' in info: icon_file = info['CFBundleIconFile'] icon_path = objc.currentBundle().pathForImageResource_(icon_file) if icon_path is not None: icon = NSImage.alloc().initWithContentsOfFile_(icon_path) if icon is None: icon = NSImage.imageNamed_('NSApplicationIcon') options = {'Credits': NSAttributedString.alloc().initWithString_('ÇFULLUSERNAMEÈ'), 'ApplicationName': self.name(), 'ApplicationIcon': icon, 'ApplicationVersion': info['CFBundleShortVersionString'], 'Version': 'Coda %s' % NSBundle.mainBundle().infoDictionary()['CFBundleShortVersionString']} NSApp.orderFrontStandardAboutPanelWithOptions_(options)
def hide_dock_icon(): """Don't show the dock icon for the app.""" path_to_current_bundle = objc.currentBundle().bundlePath() path_to_plist = "{}/Contents/Info.plist".format(path_to_current_bundle) plist = plistlib.readPlist(path_to_plist) plist["LSUIElement"] = "1" plistlib.writePlist(plist, path_to_plist) print("Done! Run Sentinel again.")
def _extractClassesFromNibFromBundle(self, nibName, bundle=None): if not bundle: bundle = objc.currentBundle() if nibName[-4:] == '.nib': resType = None else: resType = "nib" path = bundle.pathForResource_ofType_(nibName, resType) if not path: raise NibLoaderError("Could not find nib named '%s' " "in bundle '%s'" % (nibName, bundle)) self._extractClassesFromNibFromPath(path)
# # bundle.py # ÇPROJECTNAMEÈ # # Created by ÇFULLUSERNAMEÈ on ÇDATEÈ. # Copyright ÇORGANIZATIONNAMEÈ ÇYEARÈ. All rights reserved. # # Update system path for the bundle. import sys, objc resource_path = objc.currentBundle().resourcePath() sys.path.insert(0, resource_path.stringByAppendingPathComponent_('PyObjC')) sys.path.insert(0, resource_path) # Import modules containing classes required by the bundle. import ÇPROJECTNAMEASIDENTIFIERÈ
from __future__ import with_statement from Foundation import * from AppKit import * import objc import os.path import jre.cocoa import jre.debug import InstrumentManager from ScottyController import Scotty from ScottyGlassWindow import GlassWindow ModuleBundle = objc.currentBundle() class ScottyInstrumentManager(InstrumentManager.InstrumentManager): def _loadInstrumentPlugins(self): from InstrumentLoader import InstrumentLoader searchDirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask|NSLocalDomainMask|NSNetworkDomainMask, True) appName = u"Scotty" searchDirs = [ os.path.join(baseDir, appName, u"Instruments") for baseDir in searchDirs ] searchDirs.append(os.path.join(ModuleBundle.builtInPlugInsPath(), u"Instruments")) InstrumentLoader.loadInstrumentsInSearchPaths(searchDirs) # for searchDir in searchDirs: # # print "Searching in searchDir", searchDir # if os.path.exists(searchDir): # pluginPaths = [ os.path.join(searchDir, f) for f in os.listdir(searchDir) # if f.endswith(u'.instrument') ]
from __future__ import print_function from Foundation import * import objc import sys class PyTestPlugin(NSObject): def init(self): self = super(PyTestPlugin, self).init() print('class load!!') print("Hello from py2app") print("frozen", repr(getattr(sys, "frozen", None))) return self class PyTestPlugin2(NSObject): pass print("PyTestPlugin", __name__) print(u"[inside] currentBundle %r" % (objc.currentBundle(),))
import os import objc from Foundation import * import sys try: set except NameError: from sets import Set as set old_path = set(sys.path) old_modules = set(sys.modules) bndl = NSBundle.bundleWithPath_(os.path.abspath('dist/PyTestPlugin.pbplugin')) NSLog(u'currentBundle = %r' % (objc.currentBundle(),)) PyTestPlugin = bndl.classNamed_('PyTestPlugin') NSLog(u'PyTestPlugin = %r' % (PyTestPlugin,)) PyTestPlugin.alloc().init() NSLog(u'currentBundle = %r' % (objc.currentBundle(),)) NSLog(u'paths changed: %r' % (set(sys.path) - old_path)) NSLog(u'new modules: %r' % (set(sys.modules) - old_modules))
from Foundation import * import objc import sys class PyTestPlugin(NSObject): def init(self): self = super(PyTestPlugin, self).init() print 'class load!!' print "Hello from py2app" print "frozen", repr(getattr(sys, "frozen", None)) return self class PyTestPlugin2(NSObject): pass print "PyTestPlugin", __name__ print u"[inside] currentBundle %r" % (objc.currentBundle(),)