本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setFont方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setFont方法的具体用法?Python QStandardItem.setFont怎么用?Python QStandardItem.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setFont方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUi
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFont [as 别名]
def initUi(self, options, enabledOptions, headerOptions, singleSelectionMode):
boldFont = QFont()
boldFont.setBold(True)
# set the selection mode
if not singleSelectionMode:
self.listView_options.setSelectionMode(QAbstractItemView.ExtendedSelection)
# create enableItems if none
if enabledOptions is None:
enabledOptions = [True for idx in range(len(options))]
# Insert the choices
self.standaredItemModel = QStandardItemModel(self.listView_options)
self.standaredItemModel.itemChanged.connect(self.onItemChanged)
for idx in range(len(options)):
standaredItem = QStandardItem(options[idx])
standaredItem.setSelectable(enabledOptions[idx])
if idx in headerOptions:
standaredItem.setFont(boldFont)
self.standaredItemModel.appendRow(standaredItem)
self.listView_options.setModel(self.standaredItemModel)
# disable select all / de select all buttons if in single selection
# mode
if singleSelectionMode:
self.pushButton_sellectAll.setDisabled(True)
self.pushButton_deSellectAll.setDisabled(True)
示例2: add_parent_item
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFont [as 别名]
def add_parent_item(self, text):
item = QStandardItem(text)
item.setFlags(item.flags() & ~(Qt.ItemIsEnabled | Qt.ItemIsSelectable))
item.setData("parent", Qt.AccessibleDescriptionRole)
font = item.font()
font.setBold(True)
item.setFont(font)
self.model().appendRow(item)
示例3: HelpWebSearchWidget
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFont [as 别名]
#.........这里部分代码省略.........
if not globalSettings.testAttribute(
QWebSettings.PrivateBrowsingEnabled):
if searchText in self.__recentSearches:
self.__recentSearches.remove(searchText)
self.__recentSearches.insert(0, searchText)
if len(self.__recentSearches) > self.__maxSavedSearches:
self.__recentSearches = \
self.__recentSearches[:self.__maxSavedSearches]
self.__setupCompleterMenu()
url = self.__openSearchManager.currentEngine().searchUrl(searchText)
self.search.emit(url)
def __setupCompleterMenu(self):
"""
Private method to create the completer menu.
"""
if not self.__suggestions or \
(self.__model.rowCount() > 0 and
self.__model.item(0) != self.__suggestionsItem):
self.__model.clear()
self.__suggestionsItem = None
else:
self.__model.removeRows(1, self.__model.rowCount() - 1)
boldFont = QFont()
boldFont.setBold(True)
if self.__suggestions:
if self.__model.rowCount() == 0:
if not self.__suggestionsItem:
self.__suggestionsItem = QStandardItem(
self.tr("Suggestions"))
self.__suggestionsItem.setFont(boldFont)
self.__model.appendRow(self.__suggestionsItem)
for suggestion in self.__suggestions:
self.__model.appendRow(QStandardItem(suggestion))
if not self.__recentSearches:
self.__recentSearchesItem = QStandardItem(
self.tr("No Recent Searches"))
self.__recentSearchesItem.setFont(boldFont)
self.__model.appendRow(self.__recentSearchesItem)
else:
self.__recentSearchesItem = QStandardItem(
self.tr("Recent Searches"))
self.__recentSearchesItem.setFont(boldFont)
self.__model.appendRow(self.__recentSearchesItem)
for recentSearch in self.__recentSearches:
self.__model.appendRow(QStandardItem(recentSearch))
view = self.__completer.popup()
view.setFixedHeight(view.sizeHintForRow(0) * self.__model.rowCount() +
view.frameWidth() * 2)
self.__searchButton.setEnabled(
bool(self.__recentSearches or self.__suggestions))
def __completerActivated(self, index):
"""
Private slot handling the selection of an entry from the completer.
@param index index of the item (QModelIndex)
"""
if self.__suggestionsItem and \
示例4: populate
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFont [as 别名]
def populate(self):
"""Populate the tree view with data from the installed extensions.
"""
# TODO/Question:
# Would it make sense to move this to a dedicated model class
# complementing the FailedModel?
root = self.tree.model().invisibleRootItem()
extensions = app.extensions()
for ext in extensions.installed_extensions():
ext_infos = extensions.infos(ext)
display_name = ext_infos.get(ext, ext) if ext_infos else ext.name()
loaded_extension = extensions.get(ext)
if loaded_extension:
display_name += ' ({})'.format(loaded_extension.load_time())
name_item = QStandardItem(display_name)
name_item.extension_name = ext
name_item.setCheckable(True)
self.name_items[ext] = name_item
icon = extensions.icon(ext)
if icon:
name_item.setIcon(icon)
root.appendRow([name_item])
for entry in [
'extension-name',
'short-description',
'description',
'version',
'api-version',
'dependencies',
'maintainers',
'repository',
'website',
'license'
]:
label_item = QStandardItem('{}:'.format(
self.config_labels[entry]))
label_item.setTextAlignment(Qt.AlignTop)
bold = QFont()
bold.setWeight(QFont.Bold)
label_item.setFont(bold)
details = ext_infos.get(entry, "") if ext_infos else ""
if type(details) == list:
details = '\n'.join(details)
details_item = QStandardItem(details)
details_item.setTextAlignment(Qt.AlignTop)
if entry == 'api-version':
# Check for correct(ly formatted) api-version entry
# and highlight it in case of mismatch
api_version = appinfo.extension_api
if not details:
details_item.setFont(bold)
details_item.setText(
_("Misformat: {api}").format(details))
elif not details == api_version:
details_item.setFont(bold)
details_item.setText('{} ({}: {})'.format(
details,
appinfo.appname,
api_version))
name_item.appendRow([label_item, details_item])
示例5: populate
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFont [as 别名]
def populate(self, data):
"""Populate the data model using the data passed
from the extensions object.
The data model has up to three root-level items:
- Invalid metadata
- Failed to load
- Failed dependencies
"""
# font for use in various Items
bold = QFont()
bold.setWeight(QFont.Bold)
root = self.invisibleRootItem()
infos = data['infos']
if infos:
# Handle extensions with metadata errors
infos_item = QStandardItem()
infos_item.setFont(bold)
infos_item.setText(_("Invalid metadata:"))
infos_tooltip = (
_("Extensions whose extension.cnf file has errors.\n"
"They will be loaded nevertheless."))
infos_item.setToolTip(infos_tooltip)
root.appendRow(infos_item)
for info in infos:
name_item = QStandardItem(info)
name_item.setToolTip(infos_tooltip)
icon = self.extensions.icon(info)
if icon:
name_item.setIcon(icon)
details_item = QStandardItem(infos[info])
details_item.setToolTip(infos_tooltip)
infos_item.appendRow([name_item, details_item])
exceptions = data['exceptions']
if exceptions:
# Handle extensions that failed to load properly
import traceback
exceptions_item = self.exceptions_item = QStandardItem()
exceptions_item.setFont(bold)
exceptions_item.setText(_("Failed to load:"))
extensions_tooltip = (
_("Extensions that failed to load properly.\n"
"Double click on name to show the stacktrace.\n"
"Please contact the extension maintainer."))
exceptions_item.setToolTip(extensions_tooltip)
root.appendRow(exceptions_item)
for ext in exceptions:
extension_info = self.extensions.infos(ext)
name = (extension_info.get('extension-name', ext)
if extension_info
else ext)
name_item = QStandardItem(name)
name_item.setToolTip(extensions_tooltip)
icon = self.extensions.icon(ext)
if icon:
name_item.setIcon(icon)
exc_info = exceptions[ext]
# store exception information in the first item
name_item.exception_info = exc_info
message = '{}: {}'.format(exc_info[0].__name__, exc_info[1])
details_item = QStandardItem(message)
details_item.setToolTip(extensions_tooltip)
exceptions_item.appendRow([name_item, details_item])
dependencies = data['dependencies']
if dependencies:
# Handle extensions with dependency issues
dep_item = QStandardItem(_("Failed dependencies:"))
dep_item.setFont(bold)
dep_tooltip = (
_("Extensions with failed or circular dependencies.\n"
"They are not loaded."))
dep_item.setToolTip(dep_tooltip)
root.appendRow(dep_item)
missing = dependencies.get('missing', None)
if missing:
missing_item = QStandardItem(_("Missing:"))
missing_item.setFont(bold)
missing_item.setToolTip(dep_tooltip)
dep_item.appendRow(missing_item)
for m in missing:
item = QStandardItem(m)
item.setToolTip(dep_item)
missing_item.appendRow(item)
inactive = dependencies.get('inactive', None)
if inactive:
inactive_item = QStandardItem(_("Inactive:"))
inactive_item.setFont(bold)
inactive_item.setToolTip(dep_tooltip)
dep_item.appendRow(inactive_item)
for i in inactive:
item = QStandardItem(i)
item.setToolTip(dep_tooltip)
inactive_item.appendRow(item)
#.........这里部分代码省略.........