pyqt5_fugueicons
is a library for PyQt5 that provides the icons in the collection Fugue Icons created by Yusuke Kamiyamane. It uses the Qt Resource System to embed icons into the library, which allows them to be used directly in an
application.
> pip install pyqt5-fugueicons
import pyqt5_fugueicons as fugue
from PyQt5 import QtWidgets
icon = fugue.icon('application-blue')
button = QtWidgets.PushButton(icon, 'application-blue')
...
The above call returns the icon named "application-blue" with the dimensions 16x16. The icon can then be assigned to any QtWidgets
class that supports a QIcon
.
There are two versions of icons, shadowed and shadowless. Shadowed icons have a small
shadow, which shadowless ones don't. By default, icon()
returns the shadowed
version of an icon. This can be changed by passing the parameter shadowless=True
:
import pyqt5_fugueicons as fugue
icon = fugue.icon('application-blue', shadowless=True)
Some icons also have 24x24 and 32x32 counterparts. The parameter size
allows
one to specify the desired size of an icon, and the parameter fallback_size
defines whether the smaller counterparts of an icon should be tried if an icon
with the desired size is not found:
import pyqt5_fugueicons as fugue
icon = fugue.icon('application-blue', size=24, fallback_size=True)
In the above code, if the shadowed version of the icon "application-blue" is
not found with dimensions 24x24, the function will try to find the shadowed version
of the same icon with dimensions 16x16. If still no icon is found, an empty
QIcon
is returned. size
accepts the values 16, 24, and 32.
Icon names can be found in the author's website. An icon name
is simply its file name without the extension. The function iconNames()
returns
all icon names:
for name in fugue.iconNames():
print(name)
Animated icons in the Fugue collection are returned by the function movie()
:
import pyqt5_fugueicons as fugue
from PyQt5 import QtWidgets
movie = fugue.movie('terminal')
movie.start()
label = QtWidgets.QLabel()
label.setMovie(movie)
...
The reason the library calls it "movie" rather than "animation" is to be
consistent with Qt terminology, since Qt animations are something else. The class QMovie
is the one responsible for
showing gifs on the Qt framework, so the library follows that.
movie()
works similar to icon()
, with the difference being that there exist
only Fugue animations with the dimensions 16x16 and 24x24, so size
only accepts the
values 16 and 24. There is also a function movieNames()
which returns all movie names.
More elaborated examples of usage can be found in the folder samples
of this repository.
Since the icon files are already compiled into resource.py
, this
repository does not include the icon files from the Fugue's website.
If you want to compile it by yourself, you must download it,
extract it into the folder resources
, and run pyrcc5
:
pyrcc5 -o pyqt5_fugueicons/resources.py resources/resources.qrc
Or rcc.exe
:
rcc.exe -g python pyqt5_fugueicons/resources.py resources/resources.qrc
In the latter case, resources.py
has to be manually opened and the line
from PySide2 import QtCore
must be replaced with from PyQt5 import QtCore
.