本文整理汇总了Python中PyQt4.Qt.QSettings.fileName方法的典型用法代码示例。如果您正苦于以下问题:Python QSettings.fileName方法的具体用法?Python QSettings.fileName怎么用?Python QSettings.fileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QSettings
的用法示例。
在下文中一共展示了QSettings.fileName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import fileName [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: __init__
# 需要导入模块: from PyQt4.Qt import QSettings [as 别名]
# 或者: from PyQt4.Qt.QSettings import fileName [as 别名]
class Filterer:
def __init__(self, app):
if not hasattr(app, 'db'):
print("filters: need 'db' from app.")
exit(1)
if not hasattr(app, 'preferences'):
print("filters: need 'preferences' from app.")
exit(1)
self.app = app
self._filters = {}
self._keys = []
self._instances = ([], [])
self.settings = QSettings("blain", "filters")
def connect(self):
ui = self.app.preferences.ui
ui.filtersComboBox.currentIndexChanged.connect(self.changeDescription)
ui.filtersComboBox_new.currentIndexChanged.connect(self.changeNew)
ui.addfilterButton.clicked.connect(self.install)
ui.updatefilterButton.clicked.connect(lambda: self.update())
ui.removefilterButton.clicked.connect(self.remove)
# init filter ui stuff in preferences
self.changeNew(0)
self.changeDescription(0)
def setup(self):
app, st, pref = self.app, self.settings, self.app.preferences.ui
settingspath = dirname(str(self.settings.fileName()))
filterpath = pathjoin(settingspath, "filter")
# copy default filters into user config
if not exists(filterpath) or not isdir(filterpath):
mkdir(filterpath)
localfilterpath = pathjoin(app.cwd, "filter")
for filename in listdir(localfilterpath):
if isfile(pathjoin(localfilterpath, filename)) and \
filename.endswith(".py") and \
not exists(pathjoin(filterpath, filename)):
copyfile(pathjoin(localfilterpath, filename),
pathjoin( filterpath, filename))
# read filters from directory
for filename in listdir(filterpath):
if isfile(pathjoin(filterpath, filename)) and filename.endswith(".py"):
mname = filename[:-3]
fp, pathname, desc = find_module(mname,[filterpath])
try:
filter = load_module(mname, fp, pathname, desc)
filterinfo = fi = filter.info()
if not isinstance(filterinfo, dict) or \
not ('id' in fi and 'name' in fi and \
'filter' in fi and 'install' in \
fi and 'config' in fi and \
'filter_description' in fi and \
'instance_description' in fi and\
isinstance(fi['config'], dict)):
print "[ERROR] filter '%s' not valid." % filename
else:
filterinfo = drug(**filterinfo)
self._keys.append(filterinfo.id)
self._filters[filterinfo.id] = filterinfo
item = filterinfo.name, filterinfo.id
pref.filtersComboBox.addItem(*item)
pref.filtersComboBox_new.addItem(*item)
finally:
if fp: fp.close()
# add filters to list
for n in range(st.value('count', 0).toInt()[0]):
fid = str(st.value("id" + str(n)).toString())
fhash = str(st.value("hash" + str(n)).toString())
if fid in self._filters:
self.show_filter_instance(self._filters[fid], fhash)
else:
print "[WARNING] doens't found filter", fid
def filter_settings(self, id, hash):
return QSettings("blain", "filter-{0}-{1}".format(id, hash))
def apply(self, posts):
for i in range(len(self._instances[0])):
hs = self._instances[0][i]
id = self._instances[1][i]
st = self.filter_settings(id, hs)
posts = self._filters[id].filter(st, posts)
return posts
def changeDescription(self, index):
self.app.preferences.ui.descriptionText.setText(
self._filters[self._keys[int(index)]].filter_description)
def changeNew(self, index):
filter = self._filters[self._keys[int(index)]]
ct = self.app.preferences.ui.configTable
ct.clear()
n = 0
#.........这里部分代码省略.........