本文整理汇总了Python中PyQt4.Qt.QSettings.remove方法的典型用法代码示例。如果您正苦于以下问题:Python QSettings.remove方法的具体用法?Python QSettings.remove怎么用?Python QSettings.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QSettings
的用法示例。
在下文中一共展示了QSettings.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import remove [as 别名]
class Accounter:
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")
def connect(self):
ui = self.app.preferences.ui
ui.addaccountButton.clicked.connect(self.addAccount)
ui.removeaccountButton.clicked.connect(self.removeAccount)
cb = ui.accountserviceComboBox
cb.currentIndexChanged.connect(self.changeAccountservice)
for service in services:
cb.addItem(service.title)
cb.setCurrentIndex(1)
def setup(self):
st = self.settings
st.beginGroup("url")
for service in map(unicode, st.allKeys()):
self.urls[service] = unicode(st.value(service).toString())
st.endGroup()
st.beginGroup("service")
for service in map(unicode, st.allKeys()):
self.services[service] = unicode(st.value(service).toString())
st.endGroup()
st.beginGroup("account")
for key in map(unicode, st.allKeys()):
service = unicode(st.value(key).toString())
self.accounts[key] = drug(
service = service,
name = key.partition("/")[2],
type = self.services[service],
url = self.urls[service])
st.endGroup()
for key, account in self.accounts.items():
self._accounts.append(key)
self.add_account_to_list(account)
self.accounts[key] = account = Account(account)
add_service(account.service,
{'api':account.api, 'search':account.search})
def add_account_to_list(self, account):
at = self.app.preferences.ui.accountList
n = at.count()
icon = self.app.icons.get_service_icon(account.service, account.url)
li = QListWidgetItem( u"{0} ({1})".format(
account.name, account.service))
if icon is not None:
li.setIcon(icon)
at.insertItem(n, li)
at.setCurrentRow(n)
def addAccount(self):
pref = self.app.preferences.ui
if pref.addaccountButton.text() == "wait":
return # already adding an account
if pref.accountidEdit.text() == "":
return # is empty
index = pref.accountserviceComboBox.currentIndex()
if index == 0 and pref.accounturlEdit.text() == "":
return # is empty too
account = drug(service = services[index].name,
name = unicode(pref.accountidEdit.text()),
type = services[index].type,
url = services[index].url)
if account.url is None:
url = unicode(pref.accounturlEdit.text())
if url.endswith("/"):
url = url[:-1]
if not "://" in url:
url = u"http://" + url
account.url = url
if account.service is None:
s = account.url.partition("//")[2].partition("/")[0].split(".")
account.service = s[-2] + s[-1]
# save new account
pref.addaccountButton.setText("wait")
st = self.settings
key = u"account/{0}/{1}".format(account.service, account.name)
if st.contains(key):
return # allready existing -> skip
st.setValue(key, account.service)
key = u"service/" + account.service
if not st.contains(key):
st.setValue(key, account.type)
#.........这里部分代码省略.........