I am begining with PyQgisPyQGIS and QgisQGIS in general. I wanted a way to create a layer via python, so i downloaded "Plugin Builder" and starded coding. Here's the code :
def activatePlugin (self):
global limitAer,limitSou ,limitOra , limitENE, limitCha, layer, QgsVectorLayer
layer = QgsVectorLayer('/Users/fse/Desktop/54_028_380_EXE_CCE_SID_CIR_001_B2/SHAPE/couche_test.shp', 'couche_test', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(layer)
if not layer.isValid():
print "Layer was not loaded!"
else:
print "Layer was loaded successfully!"
I get a "Layer was not loaded" response and a print in the OGR console telling me that the source data is invalid.
I have tried all sorts of slashes, backslashes etc... It is basically always the same.