本文整理汇总了Python中PyQt4.Qt.QTreeWidgetItem.setStatusTip方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidgetItem.setStatusTip方法的具体用法?Python QTreeWidgetItem.setStatusTip怎么用?Python QTreeWidgetItem.setStatusTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem.setStatusTip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_item
# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setStatusTip [as 别名]
def create_item(name, linear=None):
imt = container.mime_map.get(name, guess_type(name))
icat = get_category(name, imt)
category = "text" if linear is not None else ({"text": "misc"}.get(icat, icat))
item = QTreeWidgetItem(self.categories["text" if linear is not None else category], 1)
flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable
if category == "text":
flags |= Qt.ItemIsDragEnabled
if name not in cannot_be_renamed:
flags |= Qt.ItemIsEditable
item.setFlags(flags)
item.setStatusTip(0, _("Full path: ") + name)
item.setData(0, NAME_ROLE, name)
item.setData(0, CATEGORY_ROLE, category)
item.setData(0, LINEAR_ROLE, bool(linear))
item.setData(0, MIME_ROLE, imt)
set_display_name(name, item)
# TODO: Add appropriate tooltips based on the emblems
emblems = []
if name in {cover_page_name, cover_image_name}:
emblems.append("default_cover.png")
if name not in manifested_names and name not in ok_to_be_unmanifested:
emblems.append("dialog_question.png")
if linear is False:
emblems.append("arrow-down.png")
if linear is None and icat == "text":
# Text item outside spine
emblems.append("dialog_warning.png")
if category == "text" and name in processed:
# Duplicate entry in spine
emblems.append("dialog_warning.png")
render_emblems(item, emblems)
return item
示例2: build
# 需要导入模块: from PyQt4.Qt import QTreeWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTreeWidgetItem import setStatusTip [as 别名]
def build(self, container):
self.clear()
self.root = self.invisibleRootItem()
self.root.setFlags(Qt.ItemIsDragEnabled)
self.categories = {}
for category, text, icon in (
('text', _('Text'), 'keyboard-prefs.png'),
('styles', _('Styles'), 'lookfeel.png'),
('images', _('Images'), 'view-image.png'),
('fonts', _('Fonts'), 'font.png'),
('misc', _('Miscellaneous'), 'mimetypes/dir.png'),
):
self.categories[category] = i = QTreeWidgetItem(self.root, 0)
i.setText(0, text)
i.setIcon(0, QIcon(I(icon)))
f = i.font(0)
f.setBold(True)
i.setFont(0, f)
i.setData(0, NAME_ROLE, category)
flags = Qt.ItemIsEnabled
if category == 'text':
flags |= Qt.ItemIsDropEnabled
i.setFlags(flags)
processed, seen = set(), {}
def get_display_name(name, item):
parts = name.split('/')
text = parts[-1]
while text in seen and parts:
text = parts.pop() + '/' + text
seen[text] = item
return text
for name, linear in container.spine_names:
processed.add(name)
i = QTreeWidgetItem(self.categories['text'], 1)
prefix = '' if linear else '[nl] '
if not linear:
i.setIcon(self.non_linear_icon)
i.setText(0, prefix + get_display_name(name, i))
i.setStatusTip(0, _('Full path: ') + name)
i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsSelectable)
i.setData(0, NAME_ROLE, name)
font_types = {guess_type('a.'+x)[0] for x in ('ttf', 'otf', 'woff')}
def get_category(mt):
category = 'misc'
if mt.startswith('image/'):
category = 'images'
elif mt in font_types:
category = 'fonts'
elif mt in OEB_STYLES:
category = 'styles'
return category
all_files = list(container.manifest_type_map.iteritems())
all_files.append((guess_type('a.opf')[0], [container.opf_name]))
for name in container.name_path_map:
if name in processed:
continue
processed.add(name)
imt = container.mime_map.get(name, guess_type(name)[0])
icat = get_category(imt)
i = QTreeWidgetItem(self.categories[icat], 1)
i.setText(0, get_display_name(name, i))
i.setStatusTip(0, _('Full path: ') + name)
i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
i.setData(0, NAME_ROLE, name)
for c in self.categories.itervalues():
self.expandItem(c)