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


Python Foundation.NSUserDefaults类代码示例

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


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

示例1: windowResized

 def windowResized(self, window):
     posSize = self.w.getPosSize()
     Height = posSize[3]
     if Height > self.closedWindowHeight and self.isResizing is False:
         print "set new Height", Height
         NSUserDefaults.standardUserDefaults().setInteger_forKey_(Height, "ToucheWindowHeight")
         self.windowHeight = Height
开发者ID:schriftgestalt,项目名称:Touche,代码行数:7,代码来源:toucheTool.py

示例2: setCurrentHeight_

	def setCurrentHeight_(self, newHeight):
		"""
		Sets a new height for the Palette section.
		"""
		try:
			if newHeight >= self.minHeight() and newHeight <= self.maxHeight():
				NSUserDefaults.standardUserDefaults().setInteger_forKey_(newHeight, self.dialogName + ".ViewHeight")
		except:
			self.logError(traceback.format_exc())
开发者ID:schriftgestalt,项目名称:GlyphsSDK,代码行数:9,代码来源:plugins.py

示例3: set_selfcontrol_setting

def set_selfcontrol_setting(key, value, username):
    """ sets a single default setting of SelfControl for the provied username """
    NSUserDefaults.resetStandardUserDefaults()
    originalUID = os.geteuid()
    os.seteuid(getpwnam(username).pw_uid)
    CFPreferencesSetAppValue(key, value, "org.eyebeam.SelfControl")
    CFPreferencesAppSynchronize("org.eyebeam.SelfControl")
    NSUserDefaults.resetStandardUserDefaults()
    os.seteuid(originalUID)
开发者ID:andreasgrill,项目名称:auto-selfcontrol,代码行数:9,代码来源:auto-selfcontrol.py

示例4: get_selfcontrol_settings

def get_selfcontrol_settings(username):
    """ returns all default settings of SelfControl for the provided username """
    NSUserDefaults.resetStandardUserDefaults()
    originalUID = os.geteuid()
    os.seteuid(getpwnam(username).pw_uid)
    defaults = NSUserDefaults.standardUserDefaults()
    defaults.addSuiteNamed_("org.eyebeam.SelfControl")
    defaults.synchronize()
    result = defaults.dictionaryRepresentation()
    NSUserDefaults.resetStandardUserDefaults()
    os.seteuid(originalUID)
    return result
开发者ID:andreasgrill,项目名称:auto-selfcontrol,代码行数:12,代码来源:auto-selfcontrol.py

示例5: __init__

    def __init__(self):
        major, minor = platform.mac_ver()[0].split('.')[0:2]
        if NSApp.delegate().applicationName in ('Blink Lite', 'SIP2SIP'):
            return

        if (int(major) == 10 and int(minor) >= 7) or int(major) > 10:
            self.notification_center = NotificationCenter()
            enabled = NSUserDefaults.standardUserDefaults().stringForKey_("iCloudSyncEnabled")
            if enabled is None:
                NSUserDefaults.standardUserDefaults().setObject_forKey_("Enabled", "iCloudSyncEnabled")
                self.start()
            elif enabled == "Enabled" :
                self.start()

            NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "userDefaultsDidChange:", "NSUserDefaultsDidChangeNotification", NSUserDefaults.standardUserDefaults())
开发者ID:uditha-atukorala,项目名称:blink,代码行数:15,代码来源:iCloudManager.py

示例6: __init__

        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.home = expanduser('~')

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

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

            # Check out_dir exists
            if not self.get('outdir') or not isdir(self.get('outdir')):
                self.set('outdir', NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0])
开发者ID:harliquin76,项目名称:EDMarketConnector,代码行数:25,代码来源:config.py

示例7: pre_appdata_use_startup

def pre_appdata_use_startup(appdata_path):
    preload_dlls(unhandled_exc_handler)
    try:
        DOMAIN = NSString.alloc().initWithString_('com.apple.LaunchServices')
        KEYS = (NSString.alloc().initWithString_('LSArchitecturesForX86_64'), NSString.alloc().initWithString_('LSArchitecturesForX86_64v2'))
        APP = NSString.alloc().initWithString_('com.getdropbox.dropbox')
        UserDefaults = NSUserDefaults.standardUserDefaults()
        launchServices = UserDefaults.persistentDomainForName_(DOMAIN)
        if launchServices:
            for key in KEYS:
                apps = launchServices.objectForKey_(key)
                if apps and apps.get(APP):
                    apps.removeObjectForKey_(APP)
                    UserDefaults.setObject_forKey_(apps, key)
                    UserDefaults.setPersistentDomain_forName_(launchServices, DOMAIN)
                    UserDefaults.synchronize()
                    report_bad_assumption("User had 'Open using Rosetta' set.")

    except Exception:
        unhandled_exc_handler()

    if MAC_VERSION <= LEOPARD:
        try:
            psn = ProcessSerialNumber()
            Carbon.GetCurrentProcess(psn)
            TRACE('On Leopard or lower: PSN is %r', (psn.lowLongOfPSN, psn.highLongOfPSN))
        except Exception:
            unhandled_exc_handler()

    return arch.fixperms.check_and_fix_permissions(appdata_path)
开发者ID:bizonix,项目名称:DropBoxLibrarySRC,代码行数:30,代码来源:startup.py

示例8: init

    def init(self):
        if self:
            NSBundle.loadNibNamed_owner_("EnrollmentWindow", self)
            icloud_sync_enabled = NSUserDefaults.standardUserDefaults().stringForKey_("iCloudSyncEnabled")
            self.syncWithiCloudCheckbox.setHidden_(not icloud_sync_enabled)

            self.selectRadio_(self.radioMatrix)
            if not SIPManager().validateAddAccountAction():
                self.nextButton.setEnabled_(False)
                self.purchaseProLabel.setHidden_(False)

            if NSApp.delegate().contactsWindowController.first_run:
                NotificationCenter().add_observer(self, name='SIPAccountManagerDidAddAccount')

            if NSApp.delegate().applicationName == 'SIP2SIP':
                self.allowed_domains = ['sip2sip.info']
                self.syncWithiCloudCheckbox.setHidden_(True)
                self.syncWithiCloudCheckbox.setState_(NSOffState)
                self.domainButton.setHidden_(True)
                self.addressText.cell().setPlaceholderString_('[email protected]')

            if NSApp.delegate().applicationName == 'Blink':
                self.syncWithiCloudCheckbox.setHidden_(True)

        return self
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:25,代码来源:EnrollmentController.py

示例9: applicationDidFinishLaunching_

    def applicationDidFinishLaunching_(self, notification):
        #activate logging with ToggleProxy -logging 1 
        self.shouldLog = NSUserDefaults.standardUserDefaults().boolForKey_("logging")
        
        # load icon files
        self.active_image = NSImage.imageNamed_("StatusBarImage")
        self.inactive_image = NSImage.imageNamed_("StatusBarImage-inactive")
        self.no_network_image = NSImage.imageNamed_("StatusBarImage-noNetwork")
        self.active_image.setTemplate_(True)
        self.inactive_image.setTemplate_(True)
        self.no_network_image.setTemplate_(True)

        # make status bar item
        self.statusitem = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength)
        self.statusitem.retain()
        self.statusitem.setHighlightMode_(False)
        self.statusitem.setEnabled_(True)

        # insert a menu into the status bar item
        self.menu = NSMenu.alloc().init()
        self.statusitem.setMenu_(self.menu)

        # open connection to the dynamic (configuration) store
        self.store = SCDynamicStoreCreate(None, "name.klep.toggleproxy", self.dynamicStoreCallback, None)
        self.prefDict = SCNetworkProtocolGetConfiguration(SCNetworkServiceCopyProtocol(self.service, kSCNetworkProtocolTypeProxies))
        self.constructMenu()

        self.watchForProxyOrIpChanges()
        self.updateUI()
        self.setEnvVariables()
开发者ID:arnaudruffin,项目名称:OsxProxyToggler,代码行数:30,代码来源:ToggleProxy.py

示例10: __init__

    def __init__(self, ud=None):
        if ud is None:
            from Foundation import NSUserDefaults

            self.ud = NSUserDefaults.standardUserDefaults()
        else:
            self.ud = ud
开发者ID:BackupTheBerlios,项目名称:pylognotifier-svn,代码行数:7,代码来源:PreferenceBackend.py

示例11: userDefaultsDidChange_

 def userDefaultsDidChange_(self, notification):
     enabled = NSUserDefaults.standardUserDefaults().stringForKey_("iCloudSyncEnabled")
     if enabled == "Enabled":
         if self.cloud_storage is None:
             self.start()
             self.sync()
     elif self.cloud_storage is not None:
         self.stop()
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:8,代码来源:iCloudManager.py

示例12: applicationWillTerminate_

	def applicationWillTerminate_(self, notification):
		"""When the application intends to terminate, kill all running commands
			and persist the configuration."""
		print "Application is terminating"
		ds=self.table.dataSource()
		defaults=NSUserDefaults.standardUserDefaults()
		defaults.setObject_forKey_(ds.toArray(), "cmds")
		for cmd in self.pids.values():
			cmd.stopRunning()
开发者ID:dustin,项目名称:loginit,代码行数:9,代码来源:LogInit.py

示例13: AppConfigWork

    def AppConfigWork(self):
        self.appconf_found.setText(hasAppConf(unicode(self.path_input.text())) and "Yes" or "No")
        if isValidLogPath(unicode(self.path_input.text())):
            if hasVerboseLogging(unicode(self.path_input.text())):
                self.verbose_enabled.setText("Yes")
                self.verbose_button.setEnabled(False)
            else:
                self.verbose_enabled.setText("No")
                self.verbose_button.setEnabled(True)
        else:
            self.verbose_enabled.setText("No")
            self.verbose_button.setEnabled(False)

        # Give advice on Mac users' Keyboard preferences
        if platform=='darwin':
            self.appconf.setText(appconf)
            self.advice.setStyleSheet("font-size: 12pt;")

            # Adjust advice depending on whether users have to press F10 or fn-F10
            try:
                from Foundation import NSUserDefaults, NSGlobalDomain
                screenshotkey = NSUserDefaults.standardUserDefaults().persistentDomainForName_(NSGlobalDomain)["com.apple.keyboard.fnState"] and 'F10' or 'fn-F10'
            except:
                screenshotkey = 'fn-F10'	# Default setting, assuming an Apple keyboard

            # Advise if F10 is bound to a keyboard shortcut
            shortcutissue = ''
            try:
                # http://krypted.com/mac-os-x/defaults-symbolichotkeys/
                for k, v in NSUserDefaults.standardUserDefaults().persistentDomainForName_("com.apple.symbolichotkeys")["AppleSymbolicHotKeys"].iteritems():
                    if v['enabled'] and v['value']['parameters'][1] == 109 and v['value']['parameters'][2] == 0:
                        if k == '33':	# F10 was the default binding for "App Exposé" under OSX 10.6
                            shortcutissue = '<p>The F10 key is currently assigned to the shortcut &ldquo;Application&nbsp;windows&rdquo;. You will need to remove this assignment in &#xF8FF; &rarr; System&nbsp;Preferences &rarr; <a href="file:/System/Library/PreferencePanes/Expose.prefPane/">Mission&nbsp;Control</a>.</p>'
                        else:
                            shortcutissue = '<p>The F10 key is currently assigned to a keyboard shortcut. You will need to disable or remove this assignment in &#xF8FF; &rarr; System&nbsp;Preferences &rarr; <a href="file:/System/Library/PreferencePanes/Keyboard.prefPane/">Keyboard</a> &rarr; Shortcuts.</p>'
                        break
            except:
                pass
        else:
            screenshotkey = 'F10'
            shortcutissue = ''
        self.advice.setText(self.advice.text().replace('%1', screenshotkey).replace('%2', shortcutissue))
开发者ID:Marginal,项目名称:EliteOCR,代码行数:42,代码来源:setupwizard.py

示例14: add_replacements_to_defaults

def add_replacements_to_defaults():
    defaults = NSUserDefaults.standardUserDefaults()
    replacements = defaults.objectForKey_('NSUserDictionaryReplacementItems').mutableCopy()
    existing = set( x['replace'] for x in replacements )
    for key,value in my_replacements():
        if not key in existing:
            replacements.append({'replace': key,
                                 'with'   : value,
                                 'on'     : 1})
            defaults.setObject_forKey_inDomain_(replacements, 'NSUserDictionaryReplacementItems', NSGlobalDomain)
    defaults.synchronize()
开发者ID:smoofra,项目名称:config,代码行数:11,代码来源:replacements.py

示例15: initDefaults

	def initDefaults(self):
		defaults=NSUserDefaults.standardUserDefaults()
		ob=defaults.objectForKey_("cmds")
		if ob is not None:
			ds=self.table.dataSource()
			ds.loadArray(ob)
			for cmd in ds.cmds:
				if cmd.shouldBeRunning():
					self.performSelector_withObject_afterDelay_('runCommand:',
						cmd, 0.0)
			self.table.reloadData()
开发者ID:dustin,项目名称:loginit,代码行数:11,代码来源:LogInit.py


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