本文整理匯總了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: