本文整理汇总了Python中PyQt5.Qt.QIcon类的典型用法代码示例。如果您正苦于以下问题:Python QIcon类的具体用法?Python QIcon怎么用?Python QIcon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QIcon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: slotEditUser
def slotEditUser(self, item=None):
if not item:
item = self.ui.userList.currentItem()
self.ui.userList.setCurrentItem(item)
user = item.getUser()
if user.uid > -1:
self.ui.userIDCheck.setChecked(True)
self.ui.userID.setValue(user.uid)
self.ui.username.setText(user.username)
self.ui.realname.setText(user.realname)
self.ui.pass1.setText(user.passwd)
self.ui.pass2.setText(user.passwd)
if "wheel" in user.groups:
self.ui.admin.setChecked(True)
else:
self.ui.admin.setChecked(False)
self.ui.noPass.setChecked(user.no_password)
self.edititemindex = self.ui.userList.currentRow()
self.ui.createButton.setText(_("Update"))
icon = QIcon()
icon.addPixmap(QPixmap(":/gui/pics/tick.png"), QIcon.Normal, QIcon.Off)
self.ui.createButton.setIcon(icon)
self.ui.cancelButton.setVisible(self.ui.createButton.isVisible())
示例2: setup_store_checks
def setup_store_checks(self):
first_run = self.config.get('first_run', True)
# Add check boxes for each store so the user
# can disable searching specific stores on a
# per search basis.
existing = {}
for n in self.store_checks:
existing[n] = self.store_checks[n].isChecked()
self.store_checks = {}
stores_check_widget = QWidget()
store_list_layout = QGridLayout()
stores_check_widget.setLayout(store_list_layout)
icon = QIcon(I('donate.png'))
for i, x in enumerate(sorted(self.gui.istores.keys(), key=lambda x: x.lower())):
cbox = QCheckBox(x)
cbox.setChecked(existing.get(x, first_run))
store_list_layout.addWidget(cbox, i, 0, 1, 1)
if self.gui.istores[x].base_plugin.affiliate:
iw = QLabel(self)
iw.setToolTip('<p>' + _('Buying from this store supports the calibre developer: %s</p>') % self.gui.istores[x].base_plugin.author + '</p>')
iw.setPixmap(icon.pixmap(16, 16))
store_list_layout.addWidget(iw, i, 1, 1, 1)
self.store_checks[x] = cbox
store_list_layout.setRowStretch(store_list_layout.rowCount(), 10)
self.store_list.setWidget(stores_check_widget)
self.config['first_run'] = False
示例3: __init__
class CompletionCandidate:
def __init__(self, place_id, url, title, substrings):
self.value = url
self.place_id = place_id
def get_positions(text):
ans = set()
text = text.lower()
for ss in substrings:
idx = text.find(ss.lower())
if idx > -1:
ans |= set(range(idx, idx + len(ss)))
return sorted(ans)
self.left = make_highlighted_text(url, get_positions(url))
self.right = make_highlighted_text(title, get_positions(title))
self._icon = None
def adjust_size_hint(self, option, ans):
ans.setHeight(max(option.decorationSize.height() + 6, ans.height()))
@property
def icon(self):
if self._icon is None:
self._icon = QIcon()
url = places.favicon_url(self.place_id)
if url is not None:
f = QApplication.instance().disk_cache.data(QUrl(url))
if f is not None:
with closing(f):
raw = f.readAll()
p = QPixmap()
p.loadFromData(raw)
if not p.isNull():
self._icon.addPixmap(p)
return self._icon
def __repr__(self):
return self.value
def draw_item(self, painter, style, option):
option.features |= option.HasDecoration
option.icon = self.icon
text_rect = style.subElementRect(style.SE_ItemViewItemText, option, None)
x, y = text_rect.x(), text_rect.y()
y += (text_rect.height() - self.left.size().height()) // 2
if not option.icon.isNull():
icon_rect = style.subElementRect(style.SE_ItemViewItemDecoration, option, None)
icon_rect.setTop(y), icon_rect.setBottom(text_rect.bottom())
option.icon.paint(painter, icon_rect)
option.icon = QIcon()
width = (text_rect.width() // 2) - 10
painter.setClipRect(x, text_rect.y(), width, text_rect.height())
painter.drawStaticText(QPoint(x, y), self.left)
painter.setClipRect(text_rect)
x += width + 20
painter.drawStaticText(QPoint(x, y), self.right)
示例4: load_menu
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))
示例5: finalize_entry
def finalize_entry(entry):
icon_path = entry.get('Icon')
if icon_path:
ic = QIcon(icon_path)
if not ic.isNull():
pmap = ic.pixmap(48, 48)
if not pmap.isNull():
entry['icon_data'] = pixmap_to_data(pmap)
entry['MimeType'] = tuple(entry['MimeType'])
return entry
示例6: slotAdvanced
def slotAdvanced(self):
icon_path = None
if self.ui.scrollArea.isVisible():
icon_path = ":/gui/pics/expand.png"
self.time_line.start()
else:
self.ui.scrollArea.show()
icon_path = ":/gui/pics/collapse.png"
self.time_line.start()
icon = QIcon()
icon.addPixmap(QPixmap(icon_path), QIcon.Normal, QIcon.Off)
self.ui.addMoreUsers.setIcon(icon)
self.checkUsers()
示例7: cached_emblem
def cached_emblem(self, cache, name, raw_icon=None):
ans = cache.get(name, False)
if ans is not False:
return ans
sz = self.emblem_size
ans = None
if raw_icon is not None:
ans = raw_icon.pixmap(sz, sz)
elif name == ':ondevice':
ans = QIcon(I('ok.png')).pixmap(sz, sz)
elif name:
pmap = QIcon(os.path.join(config_dir, 'cc_icons', name)).pixmap(sz, sz)
if not pmap.isNull():
ans = pmap
cache[name] = ans
return ans
示例8: resetWidgets
def resetWidgets(self):
# clear all
self.edititemindex = None
self.ui.username.clear()
self.ui.realname.clear()
self.ui.pass1.clear()
self.ui.pass2.clear()
self.ui.admin.setChecked(False)
self.ui.noPass.setChecked(False)
self.ui.userIDCheck.setChecked(False)
self.ui.createButton.setEnabled(False)
if self.ui.cancelButton.isVisible():
self.ui.cancelButton.setHidden(self.sender() == self.ui.cancelButton)
self.checkUsers()
self.ui.createButton.setText(_("Add"))
icon = QIcon()
icon.addPixmap(QPixmap(":/gui/pics/user-group-new.png"), QIcon.Normal, QIcon.Off)
self.ui.createButton.setIcon(icon)
示例9: slotDeleteUser
def slotDeleteUser(self):
if self.ui.userList.currentRow() == self.edititemindex:
self.resetWidgets()
self.ui.autoLogin.setCurrentIndex(0)
_cur = self.ui.userList.currentRow()
item = self.ui.userList.item(_cur).getUser()
if item.uid in self.used_ids:
self.used_ids.remove(item.uid)
self.ui.userList.takeItem(_cur)
self.ui.autoLogin.removeItem(_cur + 1)
self.ui.createButton.setText(_("Add"))
icon = QIcon()
icon.addPixmap(QPixmap(":/gui/pics/user-group-new.png"), QIcon.Normal, QIcon.Off)
self.ui.createButton.setIcon(icon)
self.ui.cancelButton.hide()
self.checkUsers()
示例10: change_icon
def change_icon(self):
ci = self.plist.currentItem()
if ci is None:
return error_dialog(self, _('No selection'), _(
'No application selected'), show=True)
paths = choose_images(self, 'choose-new-icon-for-open-with-program', _(
'Choose new icon'))
if paths:
ic = QIcon(paths[0])
if ic.isNull():
return error_dialog(self, _('Invalid icon'), _(
'Could not load image from %s') % paths[0], show=True)
pmap = ic.pixmap(48, 48)
if not pmap.isNull():
entry = ci.data(ENTRY_ROLE)
entry['icon_data'] = pixmap_to_data(pmap)
ci.setData(ENTRY_ROLE, entry)
self.update_stored_config()
ci.setIcon(ic)
示例11: __init__
def __init__(self, title, msg=u'\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None):
QDialog.__init__(self, parent)
if icon is None:
self.l = l = QVBoxLayout(self)
else:
self.h = h = QHBoxLayout(self)
self.icon = i = QLabel(self)
if not isinstance(icon, QIcon):
icon = QIcon(I(icon))
i.setPixmap(icon.pixmap(64))
h.addWidget(i, alignment=Qt.AlignTop | Qt.AlignHCenter)
self.l = l = QVBoxLayout()
h.addLayout(l)
self.setWindowIcon(icon)
self.title_label = t = QLabel(title)
self.setWindowTitle(title)
t.setStyleSheet('QLabel { font-weight: bold }'), t.setAlignment(Qt.AlignCenter), t.setTextFormat(Qt.PlainText)
l.addWidget(t)
self.bar = b = QProgressBar(self)
b.setMinimum(min), b.setMaximum(max), b.setValue(min)
l.addWidget(b)
self.message = m = QLabel(self)
fm = QFontMetrics(self.font())
m.setAlignment(Qt.AlignCenter), m.setMinimumWidth(fm.averageCharWidth() * 80), m.setTextFormat(Qt.PlainText)
l.addWidget(m)
self.msg = msg
self.button_box = bb = QDialogButtonBox(QDialogButtonBox.Abort, self)
bb.rejected.connect(self._canceled)
l.addWidget(bb)
self.setWindowModality(Qt.ApplicationModal)
self.canceled = False
if not cancelable:
bb.setVisible(False)
self.cancelable = cancelable
self.resize(self.sizeHint())
示例12: __init__
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
示例13: icon
def icon(self):
if self._icon is None:
self._icon = QIcon()
url = places.favicon_url(self.place_id)
if url is not None:
f = QApplication.instance().disk_cache.data(QUrl(url))
if f is not None:
with closing(f):
raw = f.readAll()
p = QPixmap()
p.loadFromData(raw)
if not p.isNull():
self._icon.addPixmap(p)
return self._icon
示例14: icon_data_for_filename
def icon_data_for_filename(fname, size=64):
''' Return the file type icon (as bytes) for the given filename '''
raw = b''
if fname:
if not hasattr(icon_data_for_filename, 'md'):
icon_data_for_filename.md = QMimeDatabase()
for mt in icon_data_for_filename.md.mimeTypesForFileName(fname):
icname = mt.iconName()
if icname:
ic = QIcon.fromTheme(icname)
if not ic.isNull():
raw = icon_to_data(ic)
if raw:
break
return raw
示例15: __init__
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setAttribute(Qt.WA_DeleteOnClose, False)
self.queue = []
self.do_pop.connect(self.pop, type=Qt.QueuedConnection)
self._layout = l = QGridLayout()
self.setLayout(l)
self.icon = QIcon(I('dialog_error.png'))
self.setWindowIcon(self.icon)
self.icon_label = QLabel()
self.icon_label.setPixmap(self.icon.pixmap(68, 68))
self.icon_label.setMaximumSize(QSize(68, 68))
self.msg_label = QLabel('<p> ')
self.msg_label.setStyleSheet('QLabel { margin-top: 1ex; }')
self.msg_label.setWordWrap(True)
self.msg_label.setTextFormat(Qt.RichText)
self.det_msg = QPlainTextEdit(self)
self.det_msg.setVisible(False)
self.bb = QDialogButtonBox(QDialogButtonBox.Close, parent=self)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
self.ctc_button = self.bb.addButton(_('&Copy to clipboard'),
self.bb.ActionRole)
self.ctc_button.clicked.connect(self.copy_to_clipboard)
self.retry_button = self.bb.addButton(_('&Retry'), self.bb.ActionRole)
self.retry_button.clicked.connect(self.retry)
self.retry_func = None
self.show_det_msg = _('Show &details')
self.hide_det_msg = _('Hide &details')
self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole)
self.det_msg_toggle.clicked.connect(self.toggle_det_msg)
self.det_msg_toggle.setToolTip(
_('Show detailed information about this error'))
self.suppress = QCheckBox(self)
l.addWidget(self.icon_label, 0, 0, 1, 1)
l.addWidget(self.msg_label, 0, 1, 1, 1)
l.addWidget(self.det_msg, 1, 0, 1, 2)
l.addWidget(self.suppress, 2, 0, 1, 2, Qt.AlignLeft|Qt.AlignBottom)
l.addWidget(self.bb, 3, 0, 1, 2, Qt.AlignRight|Qt.AlignBottom)
l.setColumnStretch(1, 100)
self.setModal(False)
self.suppress.setVisible(False)
self.do_resize()