当前位置: 首页>>代码示例>>Python>>正文


Python NSMutableDictionary.dictionaryWithDictionary_方法代码示例

本文整理汇总了Python中Foundation.NSMutableDictionary.dictionaryWithDictionary_方法的典型用法代码示例。如果您正苦于以下问题:Python NSMutableDictionary.dictionaryWithDictionary_方法的具体用法?Python NSMutableDictionary.dictionaryWithDictionary_怎么用?Python NSMutableDictionary.dictionaryWithDictionary_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Foundation.NSMutableDictionary的用法示例。


在下文中一共展示了NSMutableDictionary.dictionaryWithDictionary_方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testFunctions

# 需要导入模块: from Foundation import NSMutableDictionary [as 别名]
# 或者: from Foundation.NSMutableDictionary import dictionaryWithDictionary_ [as 别名]
    def testFunctions(self):
        ref = SCPreferencesCreate(None, "pyobjc.test", "pyobjc.test")
        self.assertIsInstance(ref, SCPreferencesRef)

        r = SCPreferencesAddValue(ref, "use",
                NSMutableDictionary.dictionaryWithDictionary_(
                    { "python2": True, "python3": False }))
        self.assertTrue(r)

        v = SCPreferencesPathCreateUniqueChild(ref, "/")
        self.assertIsInstance(v, unicode)

        v = SCPreferencesPathGetValue(ref, "/use")
        self.assertIsInstance(v, NSDictionary)

        v = SCPreferencesPathSetValue(ref, "/use", dict(python2=True, python3=True))
        self.assertTrue(v is True)

        v = SCPreferencesPathSetLink(ref, "/use_python", "/use")
        self.assertTrue(v is True)

        v = SCPreferencesPathGetLink(ref, "/use_python")
        self.assertEqual(v, "/use")

        v = SCPreferencesPathRemoveValue(ref, "/use")
        self.assertTrue(v is True)
开发者ID:aosm,项目名称:pyobjc,代码行数:28,代码来源:test_scpreferencespath.py

示例2: fixSpotlight

# 需要导入模块: from Foundation import NSMutableDictionary [as 别名]
# 或者: from Foundation.NSMutableDictionary import dictionaryWithDictionary_ [as 别名]
def fixSpotlight ():
  DISABLED_ITEMS=set(["MENU_WEBSEARCH", "MENU_SPOTLIGHT_SUGGESTIONS", "OTHER", "BOOKMARKS", "MESSAGES"])
  REQUIRED_ITEM_KEYS=set(["enabled", "name"])
  BUNDLE_ID="com.apple.Spotlight"
  PREF_NAME="orderedItems"
  DEFAULT_VALUE=[
    {'enabled' : True, 'name' : 'APPLICATIONS'},
    {'enabled' : False, 'name' : 'MENU_SPOTLIGHT_SUGGESTIONS'},
    {'enabled' : True, 'name' : 'MENU_CONVERSION'},
    {'enabled' : True, 'name' : 'MENU_EXPRESSION'},
    {'enabled' : True, 'name' : 'MENU_DEFINITION'},
    {'enabled' : True, 'name' : 'SYSTEM_PREFS'},
    {'enabled' : True, 'name' : 'DOCUMENTS'},
    {'enabled' : True, 'name' : 'DIRECTORIES'},
    {'enabled' : True, 'name' : 'PRESENTATIONS'},
    {'enabled' : True, 'name' : 'SPREADSHEETS'},
    {'enabled' : True, 'name' : 'PDF'},
    {'enabled' : False, 'name' : 'MESSAGES'},
    {'enabled' : True, 'name' : 'CONTACT'},
    {'enabled' : True, 'name' : 'EVENT_TODO'},
    {'enabled' : True, 'name' : 'IMAGES'},
    {'enabled' : False, 'name' : 'BOOKMARKS'},
    {'enabled' : True, 'name' : 'MUSIC'},
    {'enabled' : True, 'name' : 'MOVIES'},
    {'enabled' : True, 'name' : 'FONTS'},
    {'enabled' : False, 'name' : 'MENU_OTHER'},
    {'enabled' : False, 'name' : 'MENU_WEBSEARCH'}
  ]

  items = CFPreferencesCopyValue(PREF_NAME, BUNDLE_ID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
  newItems = None
  if items is None or len(items) is 0:
    # Actual preference values are populated on demand; if the user
    # hasn't previously configured Spotlight, the preference value
    # will be unavailable
    newItems = DEFAULT_VALUE
  else:
    newItems = NSMutableArray.new()
    for item in items:
      print item['name']
      missing_keys = []
      for key in REQUIRED_ITEM_KEYS:
        if not item.has_key(key):
          missing_keys.append(key)

      if len(missing_keys) != 0:
        print "Preference item %s is missing expected keys (%s), skipping" % (item, missing_keys)
        newItems.append(item)
        continue

      if item["name"] not in DISABLED_ITEMS:
        newItems.append(item)
        continue

      newItem = NSMutableDictionary.dictionaryWithDictionary_(item)
      newItem.setObject_forKey_(0, "enabled")
      newItems.append(newItem)

  CFPreferencesSetValue(PREF_NAME, newItems, BUNDLE_ID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
  CFPreferencesSynchronize(BUNDLE_ID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
开发者ID:noroot,项目名称:fix-macosx,代码行数:62,代码来源:fix-macosx.py

示例3: SetProxy

# 需要导入模块: from Foundation import NSMutableDictionary [as 别名]
# 或者: from Foundation.NSMutableDictionary import dictionaryWithDictionary_ [as 别名]
  def SetProxy(self, enable=True, pac=CORP_PROXY):
    """Set proxy autoconfig."""

    proxies = NSMutableDictionary.dictionaryWithDictionary_(
        self.ReadProxySettings())
    logging.debug('initial proxy settings: %s', proxies)
    proxies['ProxyAutoConfigURLString'] = pac
    if enable:
      proxies['ProxyAutoConfigEnable'] = 1
    else:
      proxies['ProxyAutoConfigEnable'] = 0
    logging.debug('Setting ProxyAutoConfigURLString to %s and '
                  'ProxyAutoConfigEnable to %s', pac, enable)
    result = SCDynamicStoreSetValue(self.store,
                                    'State:/Network/Global/Proxies',
                                    proxies)
    logging.debug('final proxy settings: %s', self.ReadProxySettings())
    return result
开发者ID:AaronBurchfield,项目名称:imagr,代码行数:20,代码来源:systemconfig.py


注:本文中的Foundation.NSMutableDictionary.dictionaryWithDictionary_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。