本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setToolTip方法的具体用法?Python QStandardItem.setToolTip怎么用?Python QStandardItem.setToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setToolTip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_table
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setToolTip [as 别名]
def setup_table(self, rela):
# Table model
model = QStandardItemModel()
self.table.setModel(model)
# Set header
model.setHorizontalHeaderLabels(rela.header)
# Populate table
for row_count, row in enumerate(rela.content):
for col_count, data in enumerate(row):
item = QStandardItem()
item.setText(data)
item.setToolTip(data)
model.setItem(row_count, col_count, item)
示例2: __init__
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setToolTip [as 别名]
def __init__(self, parent):
super().__init__(parent)
self.setIconSize(QSize(48, 16))
items = []
self.icons = []
for lt in SHAPE_PRESETS.keys():
icon = LineStyleIcon(lt, self.iconSize())
self.icons.append(icon)
item = QStandardItem(icon, '')
item.setData(lt)
if ctrl.main.use_tooltips:
item.setToolTip(lt)
item.setSizeHint(self.iconSize())
items.append(item)
model = self.model()
model.setRowCount(len(items))
for r, item in enumerate(items):
model.setItem(r, 0, item)
self.view().setModel(model)
示例3: populate
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setToolTip [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)
#.........这里部分代码省略.........