3

When i'm loading my plugin into QGis 2.4 the icon doesn't appear in the toolbar. There is only an empty button. I have the icon.png in all the necessary files:

resources.py:

<RCC>
     <qresource prefix="/plugins/colorTransparency" >
        <file>icon.png</file>
     </qresource>
</RCC>

which is compiled with pyrcc4 -o resources.py resources.qrc

metadata.txt:

icon=icon.png

colorTransparency:

 def initGui(self):
    # Create action that will start plugin configuration
    self.action = QAction(
        QIcon(":/plugins/colorTransparency/icon.png"),
        u"Transparency and Random Color", self.iface.mainWindow())
    #connect the action to the run method
    self.action.triggered.connect(self.run)

    # Add toolbar button and menu item
    self.iface.addToolBarIcon(self.action)
    self.iface.addPluginToMenu(u"&TransparencyRandomColor", self.action)

def unload(self):
    # Remove the plugin menu item and icon
    self.iface.removePluginMenu(u"&TransparencyRandomColor", self.action)
    self.iface.removeToolBarIcon(self.action)

The icon.png is in the same directory and has a size of 25px x 25px.

In the plugin installer the icon is displayed. I also tried to delete it and clean everything but it doesn't work.

  • did you compiled the resource file with Make (in case of Plugin Builder) or using directly pyrcc4 compiler? – Luigi Pirelli Oct 8 '14 at 7:12
  • I've tried it with make. This did not work. Afterwards I deleted the .py file and exectued pyrcc4 manually. – Martin Oct 8 '14 at 8:11
  • 1
    if your read the make, if try to compile resources.rc giving it name as resources_rc.py => purcc4 -o resources_rc.py resources.rc. the output .py have to be the same imported in the plugin – Luigi Pirelli Oct 8 '14 at 10:29
  • Ok i did it like this and it works! – Martin Oct 21 '14 at 8:38
1

The solution for me was not to use the Plugin Builder Plugin that is recommended in the PYQgis Cookbook.

When I create the files manually everything is working fine and the icon is displayed.

0

I had the same problem.Try picture resolution 24x24 and with less shades of color.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • I tried it with 24x24 and a simple black square but it has no effect in the toolbox. – Martin Oct 2 '14 at 7:13

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.