本文整理汇总了Python中PyQt5.QtWidgets.QAction.icon方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.icon方法的具体用法?Python QAction.icon怎么用?Python QAction.icon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.icon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import icon [as 别名]
def __init__(self, action: QtWidgets.QAction):
super().__init__()
button = QtWidgets.QPushButton(action.icon(), action.text())
button.clicked.connect(action.trigger)
layout = QtWidgets.QHBoxLayout(self)
layout.addWidget(button)
示例2: TileStampsDock
# 需要导入模块: from PyQt5.QtWidgets import QAction [as 别名]
# 或者: from PyQt5.QtWidgets.QAction import icon [as 别名]
#.........这里部分代码省略.........
self.retranslateUi()
else:
pass
def keyPressEvent(self, event):
x = event.key()
if x==Qt.Key_Delete or x==Qt.Key_Backspace:
self.delete_()
return
super().keyPressEvent(event)
def currentRowChanged(self, index):
sourceIndex = self.mProxyModel.mapToSource(index)
isStamp = self.mTileStampModel.isStamp(sourceIndex)
self.mDuplicate.setEnabled(isStamp)
self.mDelete.setEnabled(sourceIndex.isValid())
self.mAddVariation.setEnabled(isStamp)
if (isStamp):
self.setStamp.emit(self.mTileStampModel.stampAt(sourceIndex))
else:
variation = self.mTileStampModel.variationAt(sourceIndex)
if variation:
# single variation clicked, use it specifically
self.setStamp.emit(TileStamp(Map(variation.map)))
def showContextMenu(self, pos):
index = self.mTileStampView.indexAt(pos)
if (not index.isValid()):
return
menu = QMenu()
sourceIndex = self.mProxyModel.mapToSource(index)
if (self.mTileStampModel.isStamp(sourceIndex)):
addStampVariation = QAction(self.mAddVariation.icon(), self.mAddVariation.text(), menu)
deleteStamp = QAction(self.mDelete.icon(), self.tr("Delete Stamp"), menu)
deleteStamp.triggered.connect(self.delete_)
addStampVariation.triggered.connect(self.addVariation)
menu.addAction(addStampVariation)
menu.addSeparator()
menu.addAction(deleteStamp)
else :
removeVariation = QAction(QIcon(":/images/16x16/remove.png"),
self.tr("Remove Variation"),
menu)
Utils.setThemeIcon(removeVariation, "remove")
removeVariation.triggered.connect(self.delete_)
menu.addAction(removeVariation)
menu.exec(self.mTileStampView.viewport().mapToGlobal(pos))
def newStamp(self):
stamp = self.mTileStampManager.createStamp()
if (self.isVisible() and not stamp.isEmpty()):
stampIndex = self.mTileStampModel.index(stamp)
if (stampIndex.isValid()):
viewIndex = self.mProxyModel.mapFromSource(stampIndex)
self.mTileStampView.setCurrentIndex(viewIndex)
self.mTileStampView.edit(viewIndex)
def delete_(self):
index = self.mTileStampView.currentIndex()
if (not index.isValid()):
return
sourceIndex = self.mProxyModel.mapToSource(index)
self.mTileStampModel.removeRow(sourceIndex.row(), sourceIndex.parent())