本文整理汇总了Python中PyQt4.Qt.QTreeWidget.resizeColumnToContents方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidget.resizeColumnToContents方法的具体用法?Python QTreeWidget.resizeColumnToContents怎么用?Python QTreeWidget.resizeColumnToContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget.resizeColumnToContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CheckLibraryDialog
# 需要导入模块: from PyQt4.Qt import QTreeWidget [as 别名]
# 或者: from PyQt4.Qt.QTreeWidget import resizeColumnToContents [as 别名]
#.........这里部分代码省略.........
tl = Item()
tl.setText(0, h)
if fixable and list:
tl.setText(1, _('(fixable)'))
tl.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
tl.setCheckState(1, False)
self.top_level_items[attr] = tl
for problem in list:
it = Item()
if checkable:
it.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
it.setCheckState(1, False)
else:
it.setFlags(Qt.ItemIsEnabled)
it.setText(0, problem[0])
it.setData(0, Qt.UserRole, problem[2])
it.setText(1, problem[1])
tl.addChild(it)
self.all_items.append(it)
plaintext.append(','.join([h, problem[0], problem[1]]))
tree.addTopLevelItem(tl)
t = self.log
t.clear()
t.setColumnCount(2)
t.setHeaderLabels([_('Name'), _('Path from library')])
self.all_items = []
self.top_level_items = {}
self.problem_count = {}
for check in CHECKS:
builder(t, checker, check)
t.resizeColumnToContents(0)
t.resizeColumnToContents(1)
self.delete_button.setEnabled(False)
self.text_results = '\n'.join(plaintext)
def item_expanded_or_collapsed(self, item):
self.log.resizeColumnToContents(0)
self.log.resizeColumnToContents(1)
def item_changed(self, item, column):
self.fix_button.setEnabled(False)
for it in self.top_level_items.values():
if it.checkState(1):
self.fix_button.setEnabled(True)
self.delete_button.setEnabled(False)
for it in self.all_items:
if it.checkState(1):
self.delete_button.setEnabled(True)
return
def delete_marked(self):
if not confirm('<p>'+_('The marked files and folders will be '
'<b>permanently deleted</b>. Are you sure?')
+'</p>', 'check_library_editor_delete', self):
return
# Sort the paths in reverse length order so that we can be sure that
# if an item is in another item, the sub-item will be deleted first.
items = sorted(self.all_items,
key=lambda x: len(x.text(1)),
reverse=True)
for it in items: