本文整理汇总了Python中PyQt4.Qt.QSettings.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python QSettings.setValue方法的具体用法?Python QSettings.setValue怎么用?Python QSettings.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QSettings
的用法示例。
在下文中一共展示了QSettings.setValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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)
示例2: MicroblogThread
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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()
示例3: settingsValue
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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
示例4: write_settings
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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])
示例5: on_backup_folder_button_clicked
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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()
示例6: GroupsThread
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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()
示例7: __init__
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
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
示例8: setSettingsValue
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
def setSettingsValue( key, val):
syslog.syslog( syslog.LOG_DEBUG,
"DEBUG setSettingsValue %s, value: %s" %
(key, str(val)))
s = QSettings()
s.setValue( key, val)
示例9: __init__
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
class Updater:
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")
def connect(self):
win = self.app.window.ui
win.actionDoUpdates.triggered.connect(self.do)
win.actionUpdate_now.triggered.connect(self.all)
self.timer.timeout.connect(self.timer_step)
self.app.window.ui.actionDoUpdates.setChecked(
self.app.preferences.settings.value("timer/active",True).toBool())
def setup(self):
app, st, pref = self.app, self.settings, self.app.preferences.settings
self.update['user'] = app.updateUser.emit
self.update['friends'] = lambda *args: \
app.updateMicroblogging.emit(args[0],
app.preferences.settings.value(\
"account/"+args[0]+"/id").toString(),\
False, *args[2:])
friends = drug(twitter = [], identica = [])
if pref.contains("account/twitter/id"):
friends.twitter = map(unicode, QSettings("blain",
"%s-twitter-friends" % pref.value("account/twitter/id").\
toString()).allKeys())
if pref.contains("account/identica/id"):
friends.identica = map(unicode, QSettings("blain",
"%s-identica-friends" % pref.value("account/identica/id").\
toString()).allKeys())
# format: (timestamp, func, service, user, *args)
self.timers = timers = [ unicode(st.value(str(i)).toString())
for i in range(st.value("count",0).toInt()[0]) ]
# add timer entries
new_friends = ['twitter', 'identica']
new_friend = {'twitter':friends.twitter , 'identica':friends.identica}
for timer in map(lambda t: unicode(t).split(","), timers):
if timer[1] == 'user':
if timer[3] in new_friend[timer[2]]:
new_friend[timer[2]].remove(timer[3])
elif timer[1] == 'friends':
if timer[2] in new_friends:
new_friends.remove(timer[2])
for service in new_friends:
timers.append("{0},friends,{1},".format(time(),service))
for service in new_friend:
for i, user in enumerate(new_friend[service]):
new_friend[service][i] = "{0},user,{1},{2}".\
format(time(),service,user)
if new_friend['twitter'] or new_friend['identica']:
timers.extend(list(sum(zip(new_friend['identica'],
new_friend['twitter']), ())))
if len(new_friend['twitter']) > len(new_friend['identica']):
timers.extend(new_friend['twitter'][len(new_friend['identica']):])
else:
timers.extend(new_friend['identica'][len(new_friend['twitter']):])
st.setValue('count',len(timers))
for i in range(len(timers)):
st.setValue(str(i), timers[i])
self.timers = list(map(lambda t: [float(t[0])] + t[1:],
map(lambda t: unicode(t).split(","), timers)))
self.updates.user = self.user
self.updates.friends = self.friends
self.timer.setInterval(
pref.value("timer/interval",1e4).toInt()[0]) # 10 sec
if pref.value("timer/active", True).toBool():
self.timer.start()
def user(self, service, user, count , ok): # new_updates count
service, user = unicode(service), unicode(user)
cur, n = None, -1
for i, timer in enumerate(self.timers):
if timer[1] == "user" and timer[2] == service and timer[3] == user:
n, cur = i, timer
break
if cur is None: return
cur[0] = time() - (not ok) * 5 - count / len(self.timers)
self.settings.setValue(str(n), ",".join(map(unicode, cur)))
def friends(self, service, user): # new_updates count
service, user = unicode(service), unicode(user)
cur, n = None, -1
for i, timer in enumerate(self.timers):
if timer[1] == "friends" and timer[2] == service:
n, cur = i, timer
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
#.........这里部分代码省略.........
# choose current data
service_level = account_leveled[timer[1]]
# dive data levels
if timer[2] in service_level:
account_level = service_level[timer[2]]
if timer[3] in account_level:
# event found, remove it
account_level.remove(timer[3])
# save left overs
t = time()
# add new group lists
timers.extend([ u"{0},groups,{1},{2},".format(t, service, account)
for service in groups_list
for account in groups_list[service] ])
# add new friend lists
timers.extend([ u"{0},friends,{1},{2},".format(t, service, account)
for service in friends_list
for account in friends_list[service] ])
# add new groups
timers.extend([ u"{0},group,{1},{2},{3}".format(t,service,account,group)
for service in groups
for account in groups[service]
for group in groups[service][account] ])
# add new friends
timers.extend([ u"{0},user,{1},{2},{3}".format(t,service,account,user)
for service in friends
for account in friends[service]
for user in friends[service][account] ])
# add some random to the order so twitter
# wont get called to often in a row hopfully
if len(timers) != st.value("count", 0).toInt()[0]:
shuffle(timers) # inplace
# save new timers
st.setValue('count',len(timers))
for i, timer in enumerate(timers):
st.setValue(str(i), timer)
# more python readable format
timers = [ unicode(t).split(",") for t in timers ]
timers = [ [float(t[0])] + t[1:] for t in timers ]
self.timers = timers
# start timers
self.updates.user = self.user
self.updates.group = self.group
self.updates.groups = self.groups
self.updates.friends = self.friends
self.timer.setInterval(
pref.value("timer/interval",1e4).toInt()[0]) # 10 sec
if pref.value("timer/active", True).toBool():
self.timer.start()
def add_timer(self, func, service, account, user, *args):
timer = ",".join(map(unicode, [time(), func, service, account, user]))
if args:
timer += "," + ",".join(map(unicode, args))
self.settings.setValue(str(len(self.timers)), timer)
timer = timer.split(",")
self.timers.append([float(timer[0])] + timer[1:])
self.settings.setValue("count", len(self.timers))
def remove_timer(self, func, service, account, user):
found, cur = [], ",".join(map(unicode, [func, service, account, user]))
for i, timer in enumerate(self.timers):
if cur in ",".join(map(unicode, timer)):
found.append(i)
示例11: __init__
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import setValue [as 别名]
class Updater:
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")
def connect(self):
win = self.app.window.ui
win.actionDoUpdates.triggered.connect(self.do)
win.actionUpdate_now.triggered.connect(self.all)
self.timer.timeout.connect(self.timer_step)
self.app.window.ui.actionDoUpdates.setChecked(
self.app.preferences.settings.value("timer/active",True).toBool())
def setup(self):
app, st, pref = self.app, self.settings, self.app.preferences.settings
account_id = {}
# thread starting functions
self.update['user'] = app.updateUser.emit
self.update['group'] = lambda *args: app.updateGroup.emit(*args[1:])
self.update['groups'] = lambda *args: \
app.updateGroups.emit(args[1], False, *args[2:])
self.update['friends'] = lambda *args: \
app.updateMicroblogging.emit(args[0],
account_id[service], False, *args[2:])
# read existing friends
friends = {}
for service in ["twitter", "identica"]:
friends[service] = []
if pref.contains("account/%s/id" % service):
account_id[service] = pref.value(
"account/%s/id" % service).toString()
friends[service] = map(unicode, QSettings("blain",
"%s-%s-friends" % (account_id[service], service)).allKeys())
friends = drug(**friends)
# read existing groups
groups = []
if pref.contains("account/identica/id"):
groups = map(unicode, QSettings("blain",
"%s-groups" % account_id['identica']).allKeys())
# format: (timestamp, func, service, user, *args)
timers = [ unicode(st.value(str(i)).toString())
for i in range(st.value("count",0).toInt()[0]) ]
# find new timer entries
new_friend = {'twitter':friends.twitter , 'identica':friends.identica}
new_friends = new_friend.keys()
new_group = groups
new_groups = True
for timer in map(lambda t: unicode(t).split(","), timers):
if timer[1] == 'user':
if timer[3] in new_friend[timer[2]]:
new_friend[timer[2]].remove(timer[3])
elif timer[1] == 'friends':
if timer[2] in new_friends:
new_friends.remove(timer[2])
elif timer[1] == 'groups':
new_groups = False
elif timer[1] == 'group':
if timer[3] in new_group:
new_group.remove(timer[3])
# add new friend lists
for service in new_friends:
timers.append("{0},friends,{1},".format(time(), service))
# add groups update timer
if new_groups and 'identica' in account_id:
timers.append("{0},groups,,{1}".\
format(time(), account_id['identica']))
# add new groups
for group in new_group:
timers.append("{0},group,,{1}".format(time(), group))
# add new friends
for service in new_friend:
for i, user in enumerate(new_friend[service]):
new_friend[service][i] = "{0},user,{1},{2}".\
format(time(),service,user)
# zip list(friends) of both services together
if new_friend['twitter'] or new_friend['identica']:
timers.extend(list(sum(zip(new_friend['identica'],
new_friend['twitter']), ())))
if len(new_friend['twitter']) > len(new_friend['identica']):
timers.extend(new_friend['twitter'][len(new_friend['identica']):])
else:
timers.extend(new_friend['identica'][len(new_friend['twitter']):])
# save new timers
st.setValue('count',len(timers))
for i in range(len(timers)):
st.setValue(str(i), timers[i])
# more python readable format
timers = [ unicode(t).split(",") for t in timers ]
#.........这里部分代码省略.........