samedi 28 février 2015

PyQGIS select layer by name, odd behavior in a plugin


I have a plugin with a function (triggered by a button) that selects a specific layer by name, then shows its attribute table. When I close the plugin and open it again, the attribute table pops up twice, and repeating this keeps adding another table popup. What's wrong?


Code:



def showTable(self):
for lyrs in QgsMapLayerRegistry.instance().mapLayers().values():
if lyrs.name() == "TestFeatures":
lyrTest = lyrs
self.iface.showAttributeTable(lyrTest)




Aucun commentaire:

Enregistrer un commentaire