I was also looking for a way to do this too and found out the way. The command
pyrcc5 -o resources.py resources.qrc
will generate resources.py
using the resources.qrc
is input.
To change your icon:
- create the file
resources.qrc
with content like this:
<RCC>
<qresource prefix="/plugins/your_plugin" >
<file>logo.svg</file>
</qresource>
</RCC>
Make sure logo.svg
or your icon is in the root directory of your plugin.
Run: pyrcc5 -o resources.py resources.qrc
To reiterate, resources.py
does not exist before you run this command. resources.py
will be generated after this command.
- Import
resources.py
in your script and call for the icon:
from qgis.PyQt.QtGui import QIcon
from qgis.core import QgsProcessingProvider
from . import resources
class YourAlgorithmProvider(QgsProcessingProvider):
# some class definitions here
def icon(self):
return QIcon(':/plugins/your_plugin/logo.svg')
qrc
file. So that you don't need to usepyrcc5
and to generateresource.py
file.resources.py
successfully". If not so, what do you mean by "it updates perfectly"?