I am getting blank outputs for button images in a custom toolbar. Although the button information populates the dockable toolbar, they lack respective icons [see Fig.1]
Much of the following code was referenced from Add toolbar via Python
def initGui(self):
# Add toolbar
self.toolbar = self.iface.addToolBar("Graphic Groundwater")
self.toolbar.setObjectName("Graphic Groundwater")
# Create actions
self.getDEM = QAction(QIcon(":/plugins/GraphicGroundwater/icons/getDEM.png"),
QCoreApplication.translate("Groundwater Modeling", "Get DEM Map"),
self.iface.mainWindow())
self.getTopo = QAction(QIcon(":/plugins/GraphicGroundwater/icons/getTopo.png"),
QCoreApplication.translate("Groundwater Modeling", "Get Topo Map"),
self.iface.mainWindow())
self.addBase = QAction(QIcon(":/plugins/GraphicGroundwater/icons/addBase.png"),
QCoreApplication.translate("Groundwater Modeling", "Add Base Area"),
self.iface.mainWindow())
self.addNewBase = QAction(QIcon(":/plugins/GraphicGroundwater/icons/addNewBase.png"),
QCoreApplication.translate("Groundwater Modeling", "Add New Base Area"),
self.iface.mainWindow())
self.addRiver = QAction(QIcon(":/plugins/GraphicGroundwater/icons/addRiver.png"),
QCoreApplication.translate("Groundwater Modeling", "Add River"),
self.iface.mainWindow())
self.addStress = QAction(QIcon(":/plugins/GraphicGroundwater/icons/addStress.png"),
QCoreApplication.translate("Groundwater Modeling", "Add Stress"),
self.iface.mainWindow())
self.addGrid = QAction(QIcon(":/plugins/GraphicGroundwater/icons/addGrid.png"),
QCoreApplication.translate("Groundwater Modeling", "Add Grid"),
self.iface.mainWindow())
self.refreshGrid = QAction(QIcon(":/plugins/GraphicGroundwater/icons/refreshGrid.png"),
QCoreApplication.translate("Groundwater Modeling", "Refresh Attributes"),
self.iface.mainWindow())
self.runModel = QAction(QIcon(":/plugins/GraphicGroundwater/icons/runModel.png"),
QCoreApplication.translate("Groundwater Modeling", "Run Model"),
self.iface.mainWindow())
# Connect action signals to slots
self.getDEM.triggered.connect(self.run)
self.getTopo.triggered.connect(self.run)
self.addBase.triggered.connect(self.run)
self.addNewBase.triggered.connect(self.run)
self.addRiver.triggered.connect(self.run)
self.addStress.triggered.connect(self.run)
self.addGrid.triggered.connect(self.run)
self.refreshGrid.triggered.connect(self.run)
self.runModel.triggered.connect(self.run)
# Add actions to the toolbar
self.toolbar.addAction(self.getDEM)
self.toolbar.addAction(self.getTopo)
self.toolbar.addAction(self.addBase)
self.toolbar.addAction(self.addNewBase)
self.toolbar.addAction(self.addRiver)
self.toolbar.addAction(self.addStress)
self.toolbar.addAction(self.addGrid)
self.toolbar.addAction(self.refreshGrid)
self.toolbar.addAction(self.runModel)
def unload(self):
# remove toolbar on plugin unload
del self.toolbar
[Fig.1]
The associated resource_rc file might also be of some diagnosis assistance...
<qresource prefix=":/plugins/graphicgroundwater/" >
<file>GraphicGroundwater.png</file>
<file>getDEM.png</file>
<file>getTopo.png</file>
<file>addBase.png</file>
<file>addNewBase.png</file>
<file>addRiver.png</file>
<file>addStress.png</file>
<file>addGrid.png</file>
<file>refreshGrid.png</file>
<file>runModel.png</file>
</qresource>