本文整理汇总了Python中PyQt5.Qt.QIcon方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.QIcon方法的具体用法?Python Qt.QIcon怎么用?Python Qt.QIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt
的用法示例。
在下文中一共展示了Qt.QIcon方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_item
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
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)
示例2: get_icon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def get_icon(self, icon_name):
"""
Check to see whether the icon exists as a Calibre resource
This will enable skinning if the user stores icons within a folder like:
...\AppData\Roaming\calibre\resources\images\Plugin Name\
"""
icon_path = os.path.join(config_dir, 'resources', 'images', self.name, icon_name)
if not os.path.exists(icon_path):
return get_icons(self.plugin_path, 'images/{0}'.format(icon_name))
pixmap = QPixmap()
pixmap.load(icon_path)
return QIcon(pixmap)
示例3: __init__
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def __init__(self, parent = None, url = '', width = None, height = None, isDialog = False):
super(Window, self).__init__(parent if isDialog else None)
assets.windows.append(self)
if width is None:
width = assets.manifest['width']
if height is None:
height = assets.manifest['height']
windowFlags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint
if isDialog:
windowFlags |= Qt.Dialog
else:
windowFlags |= Qt.CustomizeWindowHint
self.dragParams = {'type': 0, 'x': 0, 'y': 0, 'size': 5, 'margin': 0, 'draging': False}
self.webView = WebView(self, url)
self.api = API(self)
self.parent = parent
self.resize(width, height)
self.setMouseTracking(True)
self.setWindowFlags(windowFlags)
self.setWindowTitle('Hybrid App Engine')
self.setAttribute(Qt.WA_QuitOnClose, True)
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.setVisible(assets.manifest['visible'])
self.setResizable(assets.manifest['resizable'])
self.setFrameless(assets.manifest['frameless'])
self.setWindowIcon(QIcon(assets.manifest['icon']))
self.setTransBackground(assets.manifest['transBackground'])
# Methods
示例4: setIcon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def setIcon(self, icon):
if isinstance(icon, str):
icon = QIcon(self.api.normUrl(icon))
self.setWindowIcon(icon)
# 设置内容是否已被修改(标题中需要有[*]标志)
示例5: __init__
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def __init__(self, parent, text, icon = '', checkable = False):
super(MenuItem, self).__init__(QIcon(icon), text, parent)
if isinstance(icon, bool):
checkable = icon
icon = ''
self.setObjectName('menuItem')
self.setCheckable(checkable)
self.hovered.connect(self.onhover)
self.triggered.connect(self.ontrigger)
# 设置菜单项文字
示例6: setIcon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def setIcon(self, icon):
super(MenuItem, self).setIcon(QIcon(icon))
# 设置菜单项可选性
示例7: setIcon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def setIcon(self, icon):
if icon:
icon = QIcon(icon)
else:
icon = self.parent().windowIcon()
super(TrayIcon, self).setIcon(QIcon(icon))
# 设置右键菜单
示例8: icon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
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
示例9: icon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def icon(self):
t = self.tabref()
if t is None:
return QIcon()
return t.current_icon or QIcon()
示例10: draw_item
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def draw_item(self, painter, style, option):
option.features |= option.HasDecoration
option.icon = self.icon
text_rect = style.subElementRect(style.SE_ItemViewItemText, option, None)
if not option.icon.isNull():
icon_rect = style.subElementRect(style.SE_ItemViewItemDecoration, option, None)
option.icon.paint(painter, icon_rect, alignment=Qt.AlignBottom | Qt.AlignHCenter)
option.icon = QIcon()
x, y = text_rect.x(), text_rect.y()
y += (text_rect.height() - self.text.size().height()) // 2
painter.drawStaticText(QPoint(x, y), self.text)
示例11: get_icon
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def get_icon(name):
if not name.startswith('images/'):
name = 'images/' + name
try:
return _icon_cache[name]
except KeyError:
raw = get_data_as_file(name).read()
pixmap = QPixmap()
pixmap.loadFromData(raw)
icon = _icon_cache[name] = QIcon()
icon.addPixmap(pixmap)
return icon
示例12: loadIcons
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def loadIcons(self):
self.removeMN_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_delete.png'))
self.editMN_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_edit.png'))
self.startMN_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_rocket.png'))
self.rewards_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_money.png'))
self.details_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_search.png'))
self.ledgerImg = QPixmap(os.path.join(self.caller.imgDir, 'ledger.png'))
self.trezorImg = QPixmap(os.path.join(self.caller.imgDir, 'trezorModT.png'))
self.trezorOneImg = QPixmap(os.path.join(self.caller.imgDir, 'trezorOne.png'))
self.coldStaking_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_coldstaking.png'))
self.threeDots_icon = QPixmap(os.path.join(self.caller.imgDir, 'icon_3dots.png'))
示例13: loadIcons
# 需要导入模块: from PyQt5 import Qt [as 别名]
# 或者: from PyQt5.Qt import QIcon [as 别名]
def loadIcons(self):
self.refresh_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_refresh.png'))
self.time_icon = QPixmap(os.path.join(self.caller.imgDir, 'icon_clock.png'))
self.link_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_link.png'))
self.search_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_search.png'))
self.list_icon = QIcon(os.path.join(self.caller.imgDir, 'icon_list.png'))
self.question_icon = QPixmap(os.path.join(self.caller.imgDir, 'icon_question.png'))