QIconifyIcon#
Iconify is an icon library that includes 150,000+
icons from most major icon sets including Bootstrap, FontAwesome, Material
Design, and many more; each available as individual SVGs. Unlike the
superqt.fonticon
module, superqt.QIconifyIcon
does not require any additional
dependencies or font files to be installed. Icons are downloaded (and cached)
on-demand from the Iconify API, using pyconify
Search availble icons at https://icon-sets.iconify.design
Once you find one you like, use the key in the format "prefix:name"
to create an
icon: QIconifyIcon("bi:bell")
.
Basic Example#
from qtpy.QtCore import QSize
from qtpy.QtWidgets import QApplication, QPushButton
from superqt import QIconifyIcon
app = QApplication([])
btn = QPushButton()
btn.setIcon(QIconifyIcon("fluent-emoji-flat:alarm-clock"))
btn.setIconSize(QSize(60, 60))
btn.show()
app.exec()
superqt.QIconifyIcon
#
Bases: QIcon
QIcon backed by an iconify icon.
Iconify includes 150,000+ icons from most major icon sets including Bootstrap, FontAwesome, Material Design, and many more.
Search availble icons at https://icon-sets.iconify.design
Once you find one you like, use the key in the format "prefix:name"
to create an
icon: QIconifyIcon("bi:bell")
.
This class is a thin wrapper around the
pyconify svg_path
function. It pulls SVGs
from iconify, creates a temporary SVG file and uses it as the source for a QIcon.
SVGs are cached to disk, and persist across sessions (until pyconify.clear_cache()
is called).
Parameters are the same as QIconifyIcon.addKey
, which can be used to add
additional icons for various modes and states to the same QIcon.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*key
|
str
|
Icon set prefix and name. May be passed as a single string in the format
|
()
|
color
|
str
|
Icon color. If not provided, the icon will appear black (the icon fill color will be set to the string "currentColor"). |
None
|
flip
|
str
|
Flip icon. Must be one of "horizontal", "vertical", "horizontal,vertical" |
None
|
rotate
|
str | int
|
Rotate icon. Must be one of 0, 90, 180, 270, or 0, 1, 2, 3 (equivalent to 0, 90, 180, 270, respectively) |
None
|
dir
|
str
|
If 'dir' is not None, the file will be created in that directory, otherwise a default directory is used. |
None
|
Examples:
>>> from qtpy.QtWidgets import QPushButton
>>> from superqt import QIconifyIcon
>>> btn = QPushButton()
>>> icon = QIconifyIcon("bi:alarm-fill", color="red", rotate=90)
>>> btn.setIcon(icon)
addKey(*key, color=None, flip=None, rotate=None, dir=None, size=None, mode=QIcon.Mode.Normal, state=QIcon.State.Off)
#
Add an icon to this QIcon.
This is a variant of QIcon.addFile
that uses an iconify icon keys and
arguments instead of a file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*key
|
str
|
Icon set prefix and name. May be passed as a single string in the format
|
()
|
color
|
str
|
Icon color. If not provided, the icon will appear black (the icon fill color will be set to the string "currentColor"). |
None
|
flip
|
str
|
Flip icon. Must be one of "horizontal", "vertical", "horizontal,vertical" |
None
|
rotate
|
str | int
|
Rotate icon. Must be one of 0, 90, 180, 270, or 0, 1, 2, 3 (equivalent to 0, 90, 180, 270, respectively) |
None
|
dir
|
str
|
If 'dir' is not None, the file will be created in that directory, otherwise a default directory is used. |
None
|
size
|
QSize
|
Size specified for the icon, passed to |
None
|
mode
|
Mode
|
Mode specified for the icon, passed to |
Normal
|
state
|
State
|
State specified for the icon, passed to |
Off
|
Returns:
Type | Description |
---|---|
QIconifyIcon
|
This QIconifyIcon instance, for chaining. |