本文整理匯總了Python中qtawesome.icon方法的典型用法代碼示例。如果您正苦於以下問題:Python qtawesome.icon方法的具體用法?Python qtawesome.icon怎麽用?Python qtawesome.icon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qtawesome
的用法示例。
在下文中一共展示了qtawesome.icon方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: data
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def data(self, index, role):
"""
Re-implemented to return the icon for the current index.
Parameters
----------
index : QtCore.QModelIndex
role : int
Returns
-------
Any
"""
if role == QtCore.Qt.DecorationRole:
iconString = self.data(index, role=QtCore.Qt.DisplayRole)
return qtawesome.icon(iconString, color=self._iconColor)
return super().data(index, role)
示例2: update_box
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def update_box(self, text=None):
if text:
if self._show_icons:
self.button_icon.setIcon(qta.icon('fa.remove'))
self.button_icon.setProperty('_remove', True)
else:
if self._show_icons:
self.button_icon.setIcon(qta.icon('fa.search'))
self.button_icon.setProperty('_remove', False)
self._empty = not bool(text)
self.button_icon.setDisabled(self._empty)
# right = self.button_icon.width()
# top = self.contentsMargins().top()
# left = self.contentsMargins().left()
# bottom = self.contentsMargins().bottom()
# self.setContentsMargins(left, top, right, bottom)
示例3: _set_loop_icon
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def _set_loop_icon(self):
"""Set the icon for the loop audio button."""
if self._loop.isChecked():
loop_icon = qta.icon(
'fa5s.redo-alt',
color=self._active_color,
color_disabled=self._inactive_color,
animation=qta.Spin(self._loop)
)
else:
loop_icon = qta.icon(
'fa5s.redo-alt',
color=self._active_color,
color_disabled=self._inactive_color
)
self._loop.setIcon(loop_icon)
示例4: __init__
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def __init__(self, canvas: Canvas, figure: Figure):
""" A widget that displays a toolbar similar to the default Matplotlib toolbar (for the zoom and pan tool)
Args:
canvas: the canvas of the figure
figure: the figure
"""
super().__init__()
self.canvas = canvas
self.fig = figure
self.navi_toolbar = NavigationToolbar(self.canvas, self)
self.navi_toolbar.hide()
self._actions = self.navi_toolbar._actions
self._actions["home"] = self.addAction(self.navi_toolbar._icon("home.png"), "", self.navi_toolbar.home)
self._actions["back"] = self.addAction(self.navi_toolbar._icon("back.png"), "", self.navi_toolbar.back)
self._actions["forward"] = self.addAction(self.navi_toolbar._icon("forward.png"), "", self.navi_toolbar.forward)
self.addSeparator()
self._actions["drag"] = self.addAction(self.icon("arrow.png"), "", self.setSelect)
self._actions["drag"].setCheckable(True)
self._actions["pan"] = self.addAction(self.navi_toolbar._icon("move.png"), "", self.setPan)
self._actions["pan"].setCheckable(True)
self._actions["zoom"] = self.addAction(self.navi_toolbar._icon("zoom_to_rect.png"), "", self.setZoom)
self._actions["zoom"].setCheckable(True)
self.navi_toolbar._active = 'DRAG'
self.checkActive()
示例5: icon
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def icon(self, name: str):
""" get an icon with the given filename """
pm = QtGui.QPixmap(os.path.join(os.path.dirname(__file__), "icons", name))
if hasattr(pm, 'setDevicePixelRatio'):
pm.setDevicePixelRatio(self.canvas._dpi_ratio)
return QtGui.QIcon(pm)
示例6: getIconOfEntry
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def getIconOfEntry(self, entry: Artist) -> QtGui.QIcon:
""" get the icon of an entry """
if getattr(entry, "_draggable", None):
if entry._draggable.connected:
return qta.icon("fa.hand-paper-o")
return QtGui.QIcon()
示例7: addChild
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def addChild(self, parent_item: QtWidgets.QWidget, entry: Artist, row=None):
""" add a child to a tree view node """
if parent_item is None:
parent_item = self.model
# add item
item = myTreeWidgetItem(self.getNameOfEntry(entry))
item.expanded = False
item.entry = entry
item.setIcon(self.getIconOfEntry(entry))
item.setEditable(False)
item.sort = self.getEntrySortRole(entry)
if parent_item is None:
if row is None:
row = self.model.rowCount()
self.model.insertRow(row)
self.model.setItem(row, 0, item)
else:
if row is None:
parent_item.appendRow(item)
else:
parent_item.insertRow(row, item)
self.setItemForEntry(entry, item)
# add dummy child
if self.queryToExpandEntry(entry) is not None and len(self.queryToExpandEntry(entry)):
child = QtGui.QStandardItem("loading")
child.entry = None
child.setEditable(False)
child.setIcon(qta.icon("fa.hourglass-half"))
item.appendRow(child)
item.expanded = False
return item
示例8: __init__
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def __init__(self, parent: QtWidgets, canvas: Canvas):
""" A widget to display all curently used colors and let the user switch them.
Args:
parent: the parent widget
canvas: the figure's canvas element
"""
QtWidgets.QWidget.__init__(self)
# initialize color artist dict
self.color_artists = {}
# add update push button
self.button_update = QtWidgets.QPushButton(qta.icon("fa.refresh"), "update")
self.button_update.clicked.connect(self.updateColors)
# add color chooser layout
self.layout_right = QtWidgets.QVBoxLayout(self)
self.layout_right.addWidget(self.button_update)
self.layout_colors = QtWidgets.QVBoxLayout()
self.layout_right.addLayout(self.layout_colors)
self.layout_colors2 = QtWidgets.QVBoxLayout()
self.layout_right.addLayout(self.layout_colors2)
self.layout_buttons = QtWidgets.QVBoxLayout()
self.layout_right.addLayout(self.layout_buttons)
self.button_save = QtWidgets.QPushButton("Save Colors")
self.button_save.clicked.connect(self.saveColors)
self.layout_buttons.addWidget(self.button_save)
self.button_load = QtWidgets.QPushButton("Load Colors")
self.button_load.clicked.connect(self.loadColors)
self.layout_buttons.addWidget(self.button_load)
self.canvas = canvas
# add a text widget to allow easy copy and paste
self.colors_text_widget = QtWidgets.QTextEdit()
self.colors_text_widget.setAcceptRichText(False)
self.layout_colors2.addWidget(self.colors_text_widget)
self.colors_text_widget.textChanged.connect(self.colors_changed)
示例9: icon
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def icon(name):
if name in _icons:
return _icons[name]
args,kwargs = _icons_specs[name]
return qta.icon(*args,**kwargs)
示例10: _instance
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def _instance():
"""
Return the singleton instance of IconicFont.
Functions ``icon``, ``load_font``, ``charmap``, ``font`` and
``set_defaults`` all rebind to methods of the singleton instance of IconicFont.
"""
if _resource['iconic'] is None:
_resource['iconic'] = IconicFont(
('fa',
'fontawesome4.7-webfont.ttf',
'fontawesome4.7-webfont-charmap.json'),
('fa5',
'fontawesome5-regular-webfont.ttf',
'fontawesome5-regular-webfont-charmap.json'),
('fa5s',
'fontawesome5-solid-webfont.ttf',
'fontawesome5-solid-webfont-charmap.json'),
('fa5b',
'fontawesome5-brands-webfont.ttf',
'fontawesome5-brands-webfont-charmap.json'),
('ei', 'elusiveicons-webfont.ttf', 'elusiveicons-webfont-charmap.json'),
('mdi', 'materialdesignicons-webfont.ttf',
'materialdesignicons-webfont-charmap.json')
)
return _resource['iconic']
示例11: charmap
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def charmap(prefixed_name):
"""
Return the character map used for a given font.
Returns
-------
return_value: dict
The dictionary mapping the icon names to the corresponding unicode character.
"""
prefix, name = prefixed_name.split('.')
return _instance().charmap[prefix][name]
示例12: __init__
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def __init__(self, *names, **kwargs):
super().__init__(parent=kwargs.get('parent'))
self._icon = None
self._size = QtCore.QSize(16, 16)
self.setIcon(icon(*names, **kwargs))
示例13: setIcon
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def setIcon(self, _icon):
"""
set a new icon()
Parameters
----------
_icon: qtawesome.icon
icon to set
"""
self._icon = _icon
self.setPixmap(_icon.pixmap(self._size))
示例14: setIconSize
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def setIconSize(self, size):
"""
set icon size
Parameters
----------
size: QtCore.QSize
size of the icon
"""
self._size = size
示例15: icon
# 需要導入模塊: import qtawesome [as 別名]
# 或者: from qtawesome import icon [as 別名]
def icon(theme_name='', path='', qta_name='', qta_options=None, use_qta=None):
"""
Creates an icon from qtawesome, from theme or from path.
:param theme_name: icon name in the current theme (GNU/Linux only)
:param path: path of the icon (from file system or qrc)
:param qta_name: icon name in qtawesome
:param qta_options: the qtawesome options to use for controlling icon
rendering. If None, QTA_OPTIONS are used.
:param use_qta: True to use qtawesome, False to use icon from theme/path.
None to use the global setting: USE_QTAWESOME.
:returns: QtGui.QIcon
"""
ret_val = None
if use_qta is None:
use_qta = USE_QTAWESOME
if qta_options is None:
qta_options = QTA_OPTIONS
if qta is not None and use_qta is True:
ret_val = qta.icon(qta_name, **qta_options)
else:
if theme_name and path:
ret_val = QtGui.QIcon.fromTheme(theme_name, QtGui.QIcon(path))
elif theme_name:
ret_val = QtGui.QIcon.fromTheme(theme_name)
elif path:
ret_val = QtGui.QIcon(path)
return ret_val