本文整理汇总了Python中PyQt4.Qt.QTreeWidgetItem.flags方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidgetItem.flags方法的具体用法?Python QTreeWidgetItem.flags怎么用?Python QTreeWidgetItem.flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem.flags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_dictionaries
# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import flags [as 别名]
def build_dictionaries(self, reread=False):
all_dictionaries = builtin_dictionaries() | custom_dictionaries(reread=reread)
languages = defaultdict(lambda : defaultdict(set))
for d in all_dictionaries:
for locale in d.locales | {d.primary_locale}:
languages[locale.langcode][locale.countrycode].add(d)
bf = QFont(self.dictionaries.font())
bf.setBold(True)
itf = QFont(self.dictionaries.font())
itf.setItalic(True)
self.dictionaries.clear()
for lc in sorted(languages, key=lambda x:sort_key(calibre_langcode_to_name(x))):
i = QTreeWidgetItem(self.dictionaries, LANG)
i.setText(0, calibre_langcode_to_name(lc))
i.setData(0, Qt.UserRole, lc)
best_country = getattr(best_locale_for_language(lc), 'countrycode', None)
for countrycode in sorted(languages[lc], key=lambda x: country_map()['names'].get(x, x)):
j = QTreeWidgetItem(i, COUNTRY)
j.setText(0, country_map()['names'].get(countrycode, countrycode))
j.setData(0, Qt.UserRole, countrycode)
if countrycode == best_country:
j.setData(0, Qt.FontRole, bf)
pd = get_dictionary(DictionaryLocale(lc, countrycode))
for dictionary in sorted(languages[lc][countrycode], key=lambda d:d.name):
k = QTreeWidgetItem(j, DICTIONARY)
pl = calibre_langcode_to_name(dictionary.primary_locale.langcode)
if dictionary.primary_locale.countrycode:
pl += '-' + dictionary.primary_locale.countrycode.upper()
k.setText(0, dictionary.name or (_('<Builtin dictionary for {0}>').format(pl)))
k.setData(0, Qt.UserRole, dictionary)
if dictionary.name:
k.setFlags(k.flags() | Qt.ItemIsEditable)
if pd == dictionary:
k.setData(0, Qt.FontRole, itf)
self.dictionaries.expandAll()