本文整理匯總了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)
#.........這裏部分代碼省略.........