本文整理匯總了Python中PyQt4.Qt.QSettings.contains方法的典型用法代碼示例。如果您正苦於以下問題:Python QSettings.contains方法的具體用法?Python QSettings.contains怎麽用?Python QSettings.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.Qt.QSettings
的用法示例。
在下文中一共展示了QSettings.contains方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MicroblogThread
# 需要導入模塊: from PyQt4.Qt import QSettings [as 別名]
# 或者: from PyQt4.Qt.QSettings import contains [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()
示例2: settingsValue
# 需要導入模塊: from PyQt4.Qt import QSettings [as 別名]
# 或者: from PyQt4.Qt.QSettings import contains [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
示例3: GroupsThread
# 需要導入模塊: from PyQt4.Qt import QSettings [as 別名]
# 或者: from PyQt4.Qt.QSettings import contains [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()