本文整理汇总了Python中PyQt5.Qt.QIcon.addFile方法的典型用法代码示例。如果您正苦于以下问题:Python QIcon.addFile方法的具体用法?Python QIcon.addFile怎么用?Python QIcon.addFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QIcon
的用法示例。
在下文中一共展示了QIcon.addFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_menu
# 需要导入模块: from PyQt5.Qt import QIcon [as 别名]
# 或者: from PyQt5.Qt.QIcon import addFile [as 别名]
def load_menu(self):
self.store_list_menu.clear()
icon = QIcon()
icon.addFile(I('donate.png'), QSize(16, 16))
for n, p in sorted(self.gui.istores.items(), key=lambda x: x[0].lower()):
if p.base_plugin.affiliate:
self.store_list_menu.addAction(icon, n,
partial(self.open_store, n))
else:
self.store_list_menu.addAction(n, partial(self.open_store, n))
示例2: Matches
# 需要导入模块: from PyQt5.Qt import QIcon [as 别名]
# 或者: from PyQt5.Qt.QIcon import addFile [as 别名]
class Matches(QAbstractItemModel):
HEADERS = [_('Enabled'), _('Name'), _('No DRM'), _('Headquarters'), _('Affiliate'), _('Formats')]
HTML_COLS = [1]
def __init__(self, plugins):
QAbstractItemModel.__init__(self)
self.NO_DRM_ICON = QIcon(I('ok.png'))
self.DONATE_ICON = QIcon()
self.DONATE_ICON.addFile(I('donate.png'), QSize(16, 16))
self.all_matches = plugins
self.matches = plugins
self.filter = ''
self.search_filter = SearchFilter(self.all_matches)
self.sort_col = 1
self.sort_order = Qt.AscendingOrder
def get_plugin(self, index):
row = index.row()
if row < len(self.matches):
return self.matches[row]
else:
return None
def search(self, filter):
self.filter = filter.strip()
if not self.filter:
self.matches = self.all_matches
else:
try:
self.matches = list(self.search_filter.parse(self.filter))
except:
self.matches = self.all_matches
self.layoutChanged.emit()
self.sort(self.sort_col, self.sort_order)
def enable_all(self):
for i in xrange(len(self.matches)):
index = self.createIndex(i, 0)
data = (True)
self.setData(index, data, Qt.CheckStateRole)
def enable_none(self):
for i in xrange(len(self.matches)):
index = self.createIndex(i, 0)
data = (False)
self.setData(index, data, Qt.CheckStateRole)
def enable_invert(self):
for i in xrange(len(self.matches)):
self.toggle_plugin(self.createIndex(i, 0))
def toggle_plugin(self, index):
new_index = self.createIndex(index.row(), 0)
data = (is_disabled(self.get_plugin(index)))
self.setData(new_index, data, Qt.CheckStateRole)
def index(self, row, column, parent=QModelIndex()):
return self.createIndex(row, column)
def parent(self, index):
if not index.isValid() or index.internalId() == 0:
return QModelIndex()
return self.createIndex(0, 0)
def rowCount(self, *args):
return len(self.matches)
def columnCount(self, *args):
return len(self.HEADERS)
def headerData(self, section, orientation, role):
if role != Qt.DisplayRole:
return None
text = ''
if orientation == Qt.Horizontal:
if section < len(self.HEADERS):
text = self.HEADERS[section]
return (text)
else:
return (section+1)
def data(self, index, role):
row, col = index.row(), index.column()
result = self.matches[row]
if role in (Qt.DisplayRole, Qt.EditRole):
if col == 1:
return ('<b>%s</b><br><i>%s</i>' % (result.name, result.description))
elif col == 3:
return (result.headquarters)
elif col == 5:
return (', '.join(result.formats).upper())
elif role == Qt.DecorationRole:
if col == 2:
if result.drm_free_only:
return (self.NO_DRM_ICON)
if col == 4:
#.........这里部分代码省略.........