当前位置: 首页>>代码示例>>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;未经允许,请勿转载。