當前位置: 首頁>>代碼示例>>Python>>正文


Python NSBundle.mainBundle方法代碼示例

本文整理匯總了Python中Foundation.NSBundle.mainBundle方法的典型用法代碼示例。如果您正苦於以下問題:Python NSBundle.mainBundle方法的具體用法?Python NSBundle.mainBundle怎麽用?Python NSBundle.mainBundle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Foundation.NSBundle的用法示例。


在下文中一共展示了NSBundle.mainBundle方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: prepare_bin

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def prepare_bin(cls):
        """Find packaged borg binary. Prefer globally installed."""

        borg_in_path = shutil.which('borg')

        if borg_in_path:
            return borg_in_path
        elif sys.platform == 'darwin':
            # macOS: Look in pyinstaller bundle
            from Foundation import NSBundle
            mainBundle = NSBundle.mainBundle()

            bundled_borg = os.path.join(mainBundle.bundlePath(), 'Contents', 'Resources', 'borg-dir', 'borg.exe')
            if os.path.isfile(bundled_borg):
                return bundled_borg
        return None 
開發者ID:borgbase,項目名稱:vorta,代碼行數:18,代碼來源:borg_thread.py

示例2: __init__

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def __init__(self):
            self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname)
            if not isdir(self.app_dir):
                mkdir(self.app_dir)

            self.plugin_dir = join(self.app_dir, 'plugins')
            if not isdir(self.plugin_dir):
                mkdir(self.plugin_dir)

            self.internal_plugin_dir = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable.decode(sys.getfilesystemencoding())), pardir, 'Library', 'plugins')) or join(dirname(__file__), 'plugins')

            self.default_journal_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], 'Frontier Developments', 'Elite Dangerous')

            self.home = expanduser('~')

            self.respath = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable.decode(sys.getfilesystemencoding())), pardir, 'Resources')) or dirname(__file__)

            if not getattr(sys, 'frozen', False):
                # Don't use Python's settings if interactive
                self.identifier = 'uk.org.marginal.%s' % appname.lower()
                NSBundle.mainBundle().infoDictionary()['CFBundleIdentifier'] = self.identifier
            else:
                self.identifier = NSBundle.mainBundle().bundleIdentifier()
            self.defaults = NSUserDefaults.standardUserDefaults()
            self.settings = dict(self.defaults.persistentDomainForName_(self.identifier) or {})	# make writeable

            # Check out_dir exists
            if not self.get('outdir') or not isdir(self.get('outdir')):
                self.set('outdir', NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0]) 
開發者ID:EDCD,項目名稱:EDMarketConnector,代碼行數:31,代碼來源:config.py

示例3: __init__

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def __init__(self, path):
        bundle = NSBundle.mainBundle()
        info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
        # Did you know you can override parts of infoDictionary (Info.plist,
        # after loading) even though Apple says it's read-only?
        info['LSUIElement'] = '1'
        # Initialize our shared application instance
        NSApplication.sharedApplication()
        # Two possibilities here
        # Either the path is a directory and we really want the file inside it
        # or the path is just a real .nib file
        if os.path.isdir(path):
            # Ok, so they just saved it from Xcode, not their fault
            # let's fix the path
            path = os.path.join(path, 'keyedobjects.nib')
        with open(path, 'rb') as f:
            # get nib bytes
            buffer = memoryview
            d = buffer(f.read())
        n_obj = NSNib.alloc().initWithNibData_bundle_(d, None)
        placeholder_obj = NSObject.alloc().init()
        result, n = n_obj.instantiateWithOwner_topLevelObjects_(
            placeholder_obj, None)
        self.hidden = True
        self.nib_contents = n
        self.win = [
            x for x in self.nib_contents if x.className() == 'NSWindow'][0]
        self.views = views_dict(self.nib_contents)
        self._attached = [] 
開發者ID:macadmins,項目名稱:nudge,代碼行數:31,代碼來源:nibbler.py

示例4: _run

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def _run():
    app_name = "MNELAB"
    if sys.platform.startswith("darwin"):
        try:  # set bundle name on macOS (app name shown in the menu bar)
            from Foundation import NSBundle
        except ImportError:
            pass
        else:
            bundle = NSBundle.mainBundle()
            if bundle:
                info = (bundle.localizedInfoDictionary() or
                        bundle.infoDictionary())
                if info:
                    info["CFBundleName"] = app_name

    matplotlib.use("Qt5Agg")
    app = QApplication(sys.argv)
    app.setApplicationName(app_name)
    app.setOrganizationName("cbrnr")
    if sys.platform.startswith("darwin"):
        app.setAttribute(Qt.AA_DontShowIconsInMenus, True)
    app.setAttribute(Qt.AA_UseHighDpiPixmaps)
    model = Model()
    model.view = MainWindow(model)
    if len(sys.argv) > 1:  # open files from command line arguments
        for f in sys.argv[1:]:
            model.load(f)
    model.view.show()
    sys.exit(app.exec_()) 
開發者ID:cbrnr,項目名稱:mnelab,代碼行數:31,代碼來源:__main__.py

示例5: NSLocalizedString

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def NSLocalizedString(key, comment):
    return NSBundle.mainBundle().localizedStringForKey_value_table_(key, "", None) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:4,代碼來源:_functiondefines.py

示例6: NSLocalizedStringFromTable

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def NSLocalizedStringFromTable(key, tbl, comment):
    return NSBundle.mainBundle().localizedStringForKey_value_table_(key, "", tbl) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:4,代碼來源:_functiondefines.py

示例7: __init__

# 需要導入模塊: from Foundation import NSBundle [as 別名]
# 或者: from Foundation.NSBundle import mainBundle [as 別名]
def __init__(self, path):
        bundle = NSBundle.mainBundle()
        info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
        # Did you know you can override parts of infoDictionary (Info.plist, after loading) even though Apple says it's read-only?
        info['LSUIElement'] = '1'
        info['NSRequiresAquaSystemAppearance'] = False
        # Initialize our shared application instance
        NSApplication.sharedApplication()
        # Two possibilities here
        # Either the path is a directory and we really want the file inside it
        # or the path is just a real .nib file
        if os.path.isdir(path):
            # Ok, so they just saved it from Xcode, not their fault
            # let's fix the path
            path = os.path.join(path, 'keyedobjects.nib')
        with open(path, 'rb') as f:
            # get nib bytes
            # try py2 method first
            try:
                d = buffer(f.read())
            # fail to py3
            except NameError:
                d = memoryview(f.read())
        n_obj = NSNib.alloc().initWithNibData_bundle_(d, None)
        placeholder_obj = NSObject.alloc().init()
        result, n = n_obj.instantiateWithOwner_topLevelObjects_(placeholder_obj, None)
        self.hidden = True
        self.nib_contents = n
        self.win = [x for x in self.nib_contents if x.className() == 'NSWindow'][0]
        self.views = views_dict(self.nib_contents)
        self._attached = [] 
開發者ID:macadmins,項目名稱:nibbler,代碼行數:33,代碼來源:nibbler.py


注:本文中的Foundation.NSBundle.mainBundle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。