本文整理汇总了Python中spyderlib.qt.QtGui.QTreeWidgetItem.setDisabled方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidgetItem.setDisabled方法的具体用法?Python QTreeWidgetItem.setDisabled怎么用?Python QTreeWidgetItem.setDisabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem.setDisabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh
# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setDisabled [as 别名]
def refresh(self):
title = _('Results for ')+self.filename
self.set_title(title)
self.clear()
self.data = {}
# Populating tree
results = ((_('Convention'),
ima.icon('convention'), self.results['C:']),
(_('Refactor'),
ima.icon('refactor'), self.results['R:']),
(_('Warning'),
ima.icon('warning'), self.results['W:']),
(_('Error'),
ima.icon('error'), self.results['E:']))
for title, icon, messages in results:
title += ' (%d message%s)' % (len(messages),
's' if len(messages)>1 else '')
title_item = QTreeWidgetItem(self, [title], QTreeWidgetItem.Type)
title_item.setIcon(0, icon)
if not messages:
title_item.setDisabled(True)
modules = {}
for module, lineno, message, msg_id in messages:
basename = osp.splitext(osp.basename(self.filename))[0]
if not module.startswith(basename):
# Pylint bug
i_base = module.find(basename)
module = module[i_base:]
dirname = osp.dirname(self.filename)
if module.startswith('.') or module == basename:
modname = osp.join(dirname, module)
else:
modname = osp.join(dirname, *module.split('.'))
if osp.isdir(modname):
modname = osp.join(modname, '__init__')
for ext in ('.py', '.pyw'):
if osp.isfile(modname+ext):
modname = modname + ext
break
if osp.isdir(self.filename):
parent = modules.get(modname)
if parent is None:
item = QTreeWidgetItem(title_item, [module],
QTreeWidgetItem.Type)
item.setIcon(0, ima.icon('python'))
modules[modname] = item
parent = item
else:
parent = title_item
if len(msg_id) > 1:
text = "[%s] %d : %s" % (msg_id, lineno, message)
else:
text = "%d : %s" % (lineno, message)
msg_item = QTreeWidgetItem(parent, [text], QTreeWidgetItem.Type)
msg_item.setIcon(0, ima.icon('arrow'))
self.data[id(msg_item)] = (modname, lineno)
示例2: refresh
# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setDisabled [as 别名]
def refresh(self):
title = _("Results for ") + self.filename
self.set_title(title)
self.clear()
self.data = {}
# Populating tree
results = (
(_("Convention"), ima.icon("convention"), self.results["C:"]),
(_("Refactor"), ima.icon("refactor"), self.results["R:"]),
(_("Warning"), ima.icon("warning"), self.results["W:"]),
(_("Error"), ima.icon("error"), self.results["E:"]),
)
for title, icon, messages in results:
title += " (%d message%s)" % (len(messages), "s" if len(messages) > 1 else "")
title_item = QTreeWidgetItem(self, [title], QTreeWidgetItem.Type)
title_item.setIcon(0, icon)
if not messages:
title_item.setDisabled(True)
modules = {}
for module, lineno, message, msg_id in messages:
basename = osp.splitext(osp.basename(self.filename))[0]
if not module.startswith(basename):
# Pylint bug
i_base = module.find(basename)
module = module[i_base:]
dirname = osp.dirname(self.filename)
if module.startswith(".") or module == basename:
modname = osp.join(dirname, module)
else:
modname = osp.join(dirname, *module.split("."))
if osp.isdir(modname):
modname = osp.join(modname, "__init__")
for ext in (".py", ".pyw"):
if osp.isfile(modname + ext):
modname = modname + ext
break
if osp.isdir(self.filename):
parent = modules.get(modname)
if parent is None:
item = QTreeWidgetItem(title_item, [module], QTreeWidgetItem.Type)
item.setIcon(0, ima.icon("python"))
modules[modname] = item
parent = item
else:
parent = title_item
if len(msg_id) > 1:
text = "[%s] %d : %s" % (msg_id, lineno, message)
else:
text = "%d : %s" % (lineno, message)
msg_item = QTreeWidgetItem(parent, [text], QTreeWidgetItem.Type)
msg_item.setIcon(0, ima.icon("arrow"))
self.data[id(msg_item)] = (modname, lineno)
示例3: populate_tree
# 需要导入模块: from spyderlib.qt.QtGui import QTreeWidgetItem [as 别名]
# 或者: from spyderlib.qt.QtGui.QTreeWidgetItem import setDisabled [as 别名]
def populate_tree(self, parentItem, children_list):
"""Recursive method to create each item (and associated data) in the tree."""
for child_key in children_list:
self.item_depth += 1
(filename, line_number, function_name, file_and_line, node_type
) = self.function_info(child_key)
(primcalls, total_calls, loc_time, cum_time, callers
) = self.stats[child_key]
child_item = QTreeWidgetItem(parentItem)
self.item_list.append(child_item)
self.set_item_data(child_item, filename, line_number)
# FIXME: indexes to data should be defined by a dictionary on init
child_item.setToolTip(0, 'Function or module name')
child_item.setData(0, Qt.DisplayRole, function_name)
child_item.setIcon(0, get_icon(self.icon_list[node_type]))
child_item.setToolTip(1, _('Time in function '\
'(including sub-functions)'))
#child_item.setData(1, Qt.DisplayRole, cum_time)
child_item.setData(1, Qt.DisplayRole, '%.3f' % cum_time)
child_item.setTextAlignment(1, Qt.AlignCenter)
child_item.setToolTip(2, _('Local time in function '\
'(not in sub-functions)'))
#child_item.setData(2, Qt.DisplayRole, loc_time)
child_item.setData(2, Qt.DisplayRole, '%.3f' % loc_time)
child_item.setTextAlignment(2, Qt.AlignCenter)
child_item.setToolTip(3, _('Total number of calls '\
'(including recursion)'))
child_item.setData(3, Qt.DisplayRole, total_calls)
child_item.setTextAlignment(3, Qt.AlignCenter)
child_item.setToolTip(4, _('File:line '\
'where function is defined'))
child_item.setData(4, Qt.DisplayRole, file_and_line)
#child_item.setExpanded(True)
if self.is_recursive(child_item):
child_item.setData(4, Qt.DisplayRole, '(%s)' % _('recursion'))
child_item.setDisabled(True)
else:
callees = self.find_callees(child_key)
if self.item_depth < 3:
self.populate_tree(child_item, callees)
elif callees:
child_item.setChildIndicatorPolicy(child_item.ShowIndicator)
self.items_to_be_shown[id(child_item)] = callees
self.item_depth -= 1