How to get path for layers listed in a combobox?

المشرف العام

Administrator
طاقم الإدارة
I want to get the path of a layer in my plugin, in the console it works fine but in my plugin it gives me the error AttributeError: 'NoneType' object has no attribute 'dataProvider'

def run(self):"""Run method that performs all the real work"""# show the dialogself.dlg.show()mapCanvas = self.iface.mapCanvas()self.dlg.comboBox.clear()for i in range(mapCanvas.layerCount()-1,-1,-1): layer = mapCanvas.layer(i) layerName = layer.name() self.dlg.comboBox.addItem(layerName)# Run the dialog event loopresult = self.dlg.exec_()# See if OK was pressedif result == 1: index = self.dlg.comboBox.currentIndex() layer = self.dlg.comboBox.itemData(index) layer1 = os.path.dirname( unicode( layer.dataProvider().dataSourceUri() ) ) t = "C:/Users/slop2.tif" processing.runalg("gdalogr:slope", layer1, 1, True, True, False, 1.0, t) pass

أكثر...
 
أعلى