10

I've been writing a QGIS plugin (using the "Plugin Builder" plugin), and decided I wanted to change the icon (icon.png).

After running make deploy to rebuild the plugin locally, the new icon appears in the Plugin Manager (both in the list of plugins, and the plugin description panel). So far, so good.

However, the old icon persists in the menu, and toolbar icons.

I've established that the icon.png is correct in the metadata.txt, and is getting copied into my ~/.qgis/python/plugins/myplugin directory.

This is especially puzzling - I'm not replacing the default plugin icon, but an icon I previously created to replace the default plugin icon. So this has worked before... :/

I've tried these...

  • restarting QGIS
  • uninstall, then reinstall plugin using plugin manager
  • destroy the plugin using make derase followed by make deploy
  • reload the plugin using the "Plugin reloader" plugin

Does QGIS cache icons somewhere? That's the only explanation I can think of. If it does, is there any way to flush the cache?

I'm using QGIS 2.10.1 Pisa on Ubuntu 14.04. I'm using "Plugin Builder" version 2.8.3

I suspect it won't be a problem for anyone who hasn't installed the plugin before, but it's a bit strange.

24

Your plugin icon was converted to a byte array and saved in resources.py

So if you want to change this icon you have to compile your resources again:

pyrcc4 -o resources.py resources.qrc 
  • 1
    after following your advice, and restarting QGIS, the icon has changed.. thank you! – Steven Kay Sep 12 '15 at 23:04
  • 3
    .. and if that doesn't work, make clean followed by make deploy will remove the compiled resource and force the icon to be rebuilt – Steven Kay Oct 8 '15 at 11:25
  • This gives me invalid syntax. – Sunny Naik Jun 7 '17 at 8:26
1

In addition to dmh126's answer make sure you haven't accidentally deleted the import and thus prevented the resources python code from compiling. E.g. if your resources file is 'resources.py' -- assuming python files aren't nested -- you would search your project to make sure your code has the line:

import resources

Alternatively, you can delete resources.pyc and reload the plugin to ensure it is indeed getting compiled.

1

I had a similar problem, using QGIS Brighton 2.6.1 . I followed your intructions/tips and the solutions was:

  • Open OSGeo4W Shell and change to the plugin folder MyPlugin by typing: cd C:\Program Files\QGIS Brighton\apps\qgis\python\plugins\MyPlugin

  • Type: make clean (removes the resource_rc.py)

  • Type: make deploy (from resouce.qrc outputs new resource_rc.py)
  • In QGIS plugin manager, disable and re-enable the plugin (outputs new compiled resource_rc.pyc) And the new pictures/logos changed.

Thanks!

New contributor
Frederik Eistrup is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.