當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。