Ejemplo n.º 1
0
 def __init__(self, settings_name, key=None):
     if not key:
         settings = Settings(settings_name)  # store settings, password etc.
         settings.add_setting("do-not-change!", str, random())
         settings.load_settings()
         settings.save_settings()
         self.key = settings.get("do-not-change!")
     else:
         self.key = key
Ejemplo n.º 2
0
 def __init__(self, settings_name, key=None):
     if not key:
         settings = Settings(settings_name)  # store settings, password etc.
         settings.add_setting("do-not-change!", str, random())
         settings.load_settings()
         settings.save_settings()
         self.key = settings.get("do-not-change!")
     else:
         self.key = key
Note that after the import, you must specify your unique
reverse-domain-name-style identifier for this app. This influences the on-disk
location of the saved settings file.

Next you identify the names of the settings that will be stored, what type of
variable they are (e.g.: string, int, bool, float), and what the initial or
default value is. (You can use your own type, but it must seamlessly normalize
to and from a string. Also it would ideally be plain-text and user editable)

The call to load_settings loads the stored values for the settings you have
previously identified if they exist. (Don't bother checking first, just always
call this method.)

The previously-named settings can be accessed and changed as attributes of the
Settings object. 

The save_settings call saves any changes to disk.
"""

from usersettings import Settings

CONF = Settings('com.example.apps.UserSettingsExample')
CONF.add_setting("counter", int, default=0)
CONF.load_settings()

print "Counter:", CONF.counter
CONF.counter += 1

CONF.save_settings()
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
__author__ = 'luckydonald'


from luckydonaldUtils.store import random
from .. import IDENTIFIER

import logging

logger = logging.getLogger(__name__)


from usersettings import Settings # pip install usersettings
settings = Settings(IDENTIFIER)  # store settings, password etc.
settings.add_setting("ponyfm_user", str, "")
settings.add_setting("ponyfm_pass", str, "")
settings.add_setting("use_login", int, -1)
settings.add_setting("do-not-change!", str, random())
settings.load_settings()  # get da settings.
settings.save_settings()  # write da settings. (new ones)