本文整理汇总了Python中PyQt5.QtWidgets.QTreeWidget.sortItems方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidget.sortItems方法的具体用法?Python QTreeWidget.sortItems怎么用?Python QTreeWidget.sortItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget.sortItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import sortItems [as 别名]
def __init__(self, parent: QWidget, filename: str, torrent_info: TorrentInfo,
control_thread: 'ControlManagerThread'):
super().__init__(parent)
self._torrent_info = torrent_info
download_info = torrent_info.download_info
self._control_thread = control_thread
self._control = control_thread.control
vbox = QVBoxLayout(self)
self._download_dir = get_directory(self._control.last_download_dir)
vbox.addWidget(QLabel('Download directory:'))
vbox.addWidget(self._get_directory_browse_widget())
vbox.addWidget(QLabel('Announce URLs:'))
url_tree = QTreeWidget()
url_tree.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
url_tree.header().close()
vbox.addWidget(url_tree)
for i, tier in enumerate(torrent_info.announce_list):
tier_item = QTreeWidgetItem(url_tree)
tier_item.setText(0, 'Tier {}'.format(i + 1))
for url in tier:
url_item = QTreeWidgetItem(tier_item)
url_item.setText(0, url)
url_tree.expandAll()
vbox.addWidget(url_tree, 1)
file_tree = QTreeWidget()
file_tree.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
file_tree.setHeaderLabels(('Name', 'Size'))
file_tree.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
self._file_items = []
self._traverse_file_tree(download_info.suggested_name, download_info.file_tree, file_tree)
file_tree.sortItems(0, Qt.AscendingOrder)
file_tree.expandAll()
file_tree.itemClicked.connect(self._update_checkboxes)
vbox.addWidget(file_tree, 3)
self._selection_label = QLabel(TorrentAddingDialog.SELECTION_LABEL_FORMAT.format(
len(download_info.files), humanize_size(download_info.total_size)))
vbox.addWidget(self._selection_label)
self._button_box = QDialogButtonBox(self)
self._button_box.setOrientation(Qt.Horizontal)
self._button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
self._button_box.button(QDialogButtonBox.Ok).clicked.connect(self.submit_torrent)
self._button_box.button(QDialogButtonBox.Cancel).clicked.connect(self.close)
vbox.addWidget(self._button_box)
self.setFixedSize(450, 550)
self.setWindowTitle('Adding "{}"'.format(filename))