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


Python Qt.QSettings类代码示例

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


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

示例1: MicroblogThread

class MicroblogThread(QThread):

    def __init__(self, app, user, service, updateusers = True):
        QThread.__init__(self, app)
        self.app = app
        self.user = user
        self.service = service
        self.updateusers = updateusers
        self.friends = QSettings("blain", "%s-%s-friends" % (user, service))


    def run(self):
        if not self.service or not self.user:
            self.quit()
            return
        trys = 0
        page = -1
        new_friends = None
        try:
            friendscount = api_call(self.service, 'users/show',
                {'id': self.user})['friends_count']
        except:
            print_exc()
            self.end()
            return
        while friendscount > 0:
            page = next_page(self.service, page, new_friends)
            print "Fetching from friends page %i, %i updates remaining (%s)" % \
                (page, friendscount, self.service),"[%i]"%trys
            new_friends = get_friends(self.service, self.user, page)
            stop = False
            friendscount -= len(new_friends)
            if len(new_friends) == 0:
                trys += 1
            for friend in new_friends:
                id = str(friend['screen_name'])
                if self.friends.contains(id):
                    print id, "(found)", self.service
                    stop = True
                else:
                    print id, "(new)", self.service
                dump = json.dumps(friend)
                self.friends.setValue(id, dump)
            if stop or trys > 3: break
            #self.yieldCurrentThread()
        print "friends list up-to-date. (%s)" % self.service
        self.end()

    def end(self):
        self.app.killThread.emit("__%s__" % self.service)
        # update all users
        if self.updateusers:
            for user in self.friends.allKeys() + [self.user]:
                self.app.updateUser.emit(self.service, user)
        self.app.updates.updates.friends(self.service, user)
        print "done."
        self.quit()
开发者ID:payload,项目名称:blain,代码行数:57,代码来源:thread.py

示例2: settingsValue

 def settingsValue( key, default):
     syslog.syslog( syslog.LOG_DEBUG,
                    "DEBUG  settingsValue %s, default: %s" %
                    (key, str(default)))
     s = QSettings()
     var = s.value(key, default)
     if not s.contains(key): s.setValue( key, var)
     syslog.syslog( syslog.LOG_DEBUG,
                    "DEBUG  settingsValue %s, value:   %s" %
                    (key, var.toString()))
     return var
开发者ID:jmechnich,项目名称:appletlib,代码行数:11,代码来源:app.py

示例3: read_settings

    def read_settings(self):
        logging.debug('Reading settings')

        settings = QSettings()
        read_settings = self.defaults.copy()
        keys = settings.allKeys()

        for k in keys:
            setting_type = QTouTvSettings._settings_types[k]
            read_settings[k] = settings.value(k, type=setting_type)

        self.apply_settings(read_settings)
开发者ID:anarcat,项目名称:pytoutv,代码行数:12,代码来源:settings.py

示例4: __new__

 def __new__(cls, clear_cache = False):
     if not cls._instance:
         cls._instance = super(Settings, cls).__new__(cls)
         cls._instance.signals = Settings.signals()
         QSettings.setDefaultFormat(QSettings.IniFormat)
         log.DEBUG("saving settings in file %s" %(QSettings().fileName()));
         cls._instance._settings = QSettings()
         cls._defaults = {
              Settings.DOTA_PATH_KEY: dota_path_default,
              Settings.STEAM_PATH_KEY: steam_path_default,
          }
     if clear_cache:
         cls._instance._cache = {}
     return cls._instance
开发者ID:OligarchButterfly,项目名称:D2ModdinPyClient,代码行数:14,代码来源:settings.py

示例5: __init__

 def __init__(self, app, user, service, updateusers = True):
     QThread.__init__(self, app)
     self.app = app
     self.user = user
     self.service = service
     self.updateusers = updateusers
     self.friends = QSettings("blain", "%s-%s-friends" % (user, service))
开发者ID:payload,项目名称:blain,代码行数:7,代码来源:thread.py

示例6: __init__

 def __init__(self, app):
     if not hasattr(app, 'db'):
         print("filters: need 'db' from app.")
         exit(1)
     self.app = app
     self._filters = {}
     self._keys = []
     self._instances = ([], [])
     self.settings = QSettings("blain", "filters")
开发者ID:koeart,项目名称:blain,代码行数:9,代码来源:filters.py

示例7: GroupsThread

class GroupsThread(QThread):

    def __init__(self, app, user, updategroups = True):
        QThread.__init__(self, app)
        self.app = app
        self.user = user
        self.updategroups = updategroups
        self.groups = QSettings("blain", "%s-groups" % user)


    def run(self):
        if not self.user:
            self.quit()
            return
        trys = 0
        new_groups = None
        while trys < 4:
            trys += 1
            new_groups = get_group(self.user)
            if new_groups is not None:
                break
        if new_groups is None:
            self.end()
            return
        for group in new_groups:
            id = str(group['nickname'])
            if self.groups.contains(id):
                print id, "(found)"
            else:
                print id, "(new)"
            dump = json.dumps(clean_urls(group))
            self.groups.setValue(id, dump)
        print "groups list up-to-date. (%s)" % self.user
        self.end()

    def end(self):
        self.app.killThread.emit("%s groups" % self.user)
        # update all groups
        if self.updategroups:
            for group in self.groups.allKeys():
                self.app.updateGroup.emit(group)
        self.app.updates.updates.groups(self.user)
        print "done."
        self.quit()
开发者ID:koeart,项目名称:blain,代码行数:44,代码来源:thread.py

示例8: __init__

 def __init__(self, app):
     if not hasattr(app, 'preferences'):
         print("update: need 'preferences' from app.")
         exit(1)
     self.app = app
     self.update = {}
     self.timers = []
     self.updates = drug()
     self.timer = QTimer(app)
     self.settings = QSettings("blain", "timers")
开发者ID:payload,项目名称:blain,代码行数:10,代码来源:update.py

示例9: setup

 def setup(self):
     st = QSettings("blain", "blain")
     st.setValue("_", 0)
     st.sync()
     settingspath = dirname(str(st.fileName()))
     self.db = db = Database(location=pathjoin(settingspath, "blain.sqlite"))
     setup_models(db)
开发者ID:dodo,项目名称:blain,代码行数:7,代码来源:database.py

示例10: __init__

 def __init__(self, app):
     if not hasattr(app, 'preferences'):
         print("accounts: need 'preferences' from app.")
         exit(1)
     if not hasattr(app, 'icons'):
         print("accounts: need 'icons' from app.")
         exit(1)
     self.app = app
     self.urls = {}
     self.services = {}
     self.accounts = {}
     self._accounts = []
     self.settings = QSettings("blain", "accounts")
开发者ID:dodo,项目名称:blain,代码行数:13,代码来源:accounts.py

示例11: __set_backup_path

    def __set_backup_path(self):

        settings = QSettings("GCI", "vertex-tools")
        settings.beginGroup("BackupSettings")
        default_path = QDir.tempPath()
        backup_path = settings.value("backup_path", default_path)
        self.backup_folder_edit.setText(backup_path)
        settings.endGroup()
开发者ID:gc-i,项目名称:vertex-tools,代码行数:8,代码来源:SnapToGridWidget.py

示例12: write_settings

    def write_settings(self):
        logging.debug('Writing settings')

        settings = QSettings()
        settings.clear()

        for k in self._settings_dict:
            if k in self.defaults:
                if self._settings_dict[k] != self.defaults[k]:
                    settings.setValue(k, self._settings_dict[k])
            else:
                msg = 'Setting key {} not found in defaults'.format(k)
                logging.warning(msg)
                settings.setValue(k, self._settings_dict[k])
开发者ID:anarcat,项目名称:pytoutv,代码行数:14,代码来源:settings.py

示例13: on_backup_folder_button_clicked

    def on_backup_folder_button_clicked(self):

        backup_path = self.backup_folder_edit.text()
        if len(backup_path) == 0:
            backup_path = QDir.tempPath()

        backup_path = QFileDialog.getExistingDirectory(self, self.tr("Select Backup Folder"), backup_path,
                                                       QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
        if len(backup_path) == 0:
            return

        self.backup_folder_edit.setText(backup_path)
        settings = QSettings("GCI", "vertex-tools")
        settings.beginGroup("BackupSettings")
        settings.setValue("backup_path", backup_path)
        settings.endGroup()
开发者ID:gc-i,项目名称:vertex-tools,代码行数:16,代码来源:SnapToGridWidget.py

示例14: __init__

class Config:
    def __init__(self, organization, product):
        self.config = QSettings(organization, product)

    def setValue(self, option, value):
        self.config.setValue(option, QVariant(value))
        self.config.sync()

    def getBoolValue(self, option):
        default = self._initValue(option, False)
        return self.config.value(option, QVariant(default)).toBool()

    def getNumValue(self, option):
        default = self._initValue(option, 0)
        return self.config.value(option, QVariant(default)).toInt()[0]

    def _initValue(self, option, value):
        if defaults.has_key(option):
            return defaults[option]
        return value
开发者ID:SamiBabat,项目名称:playground,代码行数:20,代码来源:config.py

示例15: ConfigProxy

            help=_('Show the average rating per item indication in the tag browser'))
    c.add_opt('disable_animations', default=False,
            help=_('Disable UI animations'))

    # This option is no longer used. It remains for compatibility with upgrades
    # so the value can be migrated
    c.add_opt('tag_browser_hidden_categories', default=set(),
            help=_('tag browser categories not to display'))

    c.add_opt
    return ConfigProxy(c)

config = _config()
# }}}

QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, config_dir)
QSettings.setPath(QSettings.IniFormat, QSettings.SystemScope,
        config_dir)
QSettings.setDefaultFormat(QSettings.IniFormat)

# Turn off DeprecationWarnings in windows GUI
if iswindows:
    import warnings
    warnings.simplefilter('ignore', DeprecationWarning)

def available_heights():
    desktop  = QCoreApplication.instance().desktop()
    return map(lambda x: x.height(), map(desktop.availableGeometry, range(desktop.numScreens())))

def available_height():
    desktop  = QCoreApplication.instance().desktop()
开发者ID:piewsook,项目名称:calibre,代码行数:31,代码来源:__init__.py


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