本文整理汇总了Python中AnyQt.QtWidgets.QToolButton.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setAttribute方法的具体用法?Python QToolButton.setAttribute怎么用?Python QToolButton.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EndDownloadTask
# 需要导入模块: from AnyQt.QtWidgets import QToolButton [as 别名]
# 或者: from AnyQt.QtWidgets.QToolButton import setAttribute [as 别名]
def EndDownloadTask(self, task):
future = task.future()
index = self.updateItemIndex(task.domain, task.filename)
item, tree_item, opt_widget = self.updateItems[index]
self.filesView.removeItemWidget(tree_item, 2)
opt_widget.setEnabled(True)
if future.cancelled():
# Restore the previous state
tree_item.setUpdateItem(item)
opt_widget.setState(item.state)
elif future.exception():
tree_item.setUpdateItem(item)
opt_widget.setState(item.state)
# Show the exception string in the size column.
self.warning(0, "Error while downloading. Check your connection "
"and retry.")
# recreate button for download
button = QToolButton(
None, text="Retry",
maximumWidth=120,
minimumHeight=20,
maximumHeight=20
)
if sys.platform == "darwin":
button.setAttribute(Qt.WA_MacSmallSize)
button.clicked.connect(
partial(self.SubmitDownloadTask, item.domain,
item.filename)
)
self.filesView.setItemWidget(tree_item, 2, button)
else:
# get the new updated info dict and replace the the old item
self.warning(0)
info = serverfiles.info(item.domain, item.filename)
new_item = update_item_from_info(item.domain, item.filename,
info, info)
self.updateItems[index] = (new_item, tree_item, opt_widget)
tree_item.setUpdateItem(new_item)
opt_widget.setState(new_item.state)
self.UpdateInfoLabel()
示例2: SetFilesList
# 需要导入模块: from AnyQt.QtWidgets import QToolButton [as 别名]
# 或者: from AnyQt.QtWidgets.QToolButton import setAttribute [as 别名]
def SetFilesList(self, serverInfo):
"""
Set the files to show.
"""
self.setEnabled(True)
localInfo = serverfiles.allinfo()
all_tags = set()
self.filesView.clear()
self.updateItems = []
for item in join_info_dict(localInfo, serverInfo):
tree_item = UpdateTreeWidgetItem(item)
options_widget = UpdateOptionsWidget(item.state)
options_widget.item = item
options_widget.installClicked.connect(
partial(self.SubmitDownloadTask, item.domain, item.filename)
)
options_widget.removeClicked.connect(
partial(self.SubmitRemoveTask, item.domain, item.filename)
)
self.updateItems.append((item, tree_item, options_widget))
all_tags.update(item.tags)
self.filesView.addTopLevelItems(
[tree_item for _, tree_item, _ in self.updateItems]
)
for item, tree_item, options_widget in self.updateItems:
self.filesView.setItemWidget(tree_item, 0, options_widget)
# Add an update button if the file is updateable
if item.state == OUTDATED:
button = QToolButton(
None, text="Update",
maximumWidth=120,
minimumHeight=20,
maximumHeight=20
)
if sys.platform == "darwin":
button.setAttribute(Qt.WA_MacSmallSize)
button.clicked.connect(
partial(self.SubmitDownloadTask, item.domain,
item.filename)
)
self.filesView.setItemWidget(tree_item, 2, button)
self.progress.advance()
self.filesView.setColumnWidth(0, self.filesView.sizeHintForColumn(0))
for column in range(1, 4):
contents_hint = self.filesView.sizeHintForColumn(column)
header_hint = self.filesView.header().sectionSizeHint(column)
width = max(min(contents_hint, 400), header_hint)
self.filesView.setColumnWidth(column, width)
hints = [hint for hint in sorted(all_tags) if not hint.startswith("#")]
self.completer.setTokenList(hints)
self.SearchUpdate()
self.UpdateInfoLabel()
self.toggleButtons()
self.cancelButton.setEnabled(False)
self.progress.setRange(0, 0)